Banco Andre - CPP

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <cstdio>

#include <cstdlib>
#include <queue>
using namespace std;
int main(){
int C, N;
scanf("%d%d", &C, &N);
int c[12], d[1005], t[1005];
for (int i = 0; i < C; i++)
c[i] = 0;
int cnt = 0;
for (int i = 0; i < N; i++)
scanf("%d%d", &t[i], &d[i]);
int k = 0;
queue <int> q;
for (int i = 0; k < N || !q.empty(); i++){
for (int j = 0; j < C; j++)
c[j] = max(0, c[j]-1);
while(k < N && t[k] == i){
q.push(k);
k++;
}
for (int j = 0; j < C; j++){
if (c[j] == 0 && !q.empty()){
int f = q.front();
q.pop();
if(i - t[f] > 20)
cnt++;
c[j] = d[f];
}
}
}
printf("%d\n", cnt);
return 0;
}

You might also like