-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanco.cpp
49 lines (37 loc) · 851 Bytes
/
banco.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// problem
// https://olimpiada.ic.unicamp.br/static/extras/obi2012/provas/ProvaOBI2012_f2p2.pdf
#include <bits/stdc++.h>
using namespace std;
#define maxs 1000007
int clientes[maxs][2];
int main()
{
int n,
c,
i = 0,
ans = 0;
cin >> c >> n;
priority_queue<int, vector<int>, greater<int>> que;
while(--c >= 0) que.push(0);
while(i < n)
{
cin >> clientes[i][0] >> clientes[i][1];
++i;
}
i = 0;
while(i < n)
{
int x = que.top();
que.pop();
if((x - clientes[i][0]) > 20) ++ans;
else if((x - clientes[i][0]) <= 0)
{
x = clientes[i][0];
}
x += clientes[i][1];
que.push(x);
++i;
}
printf("%d\n", ans);
return 0;
}