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 | #include <iostream> #include <cstdio> using namespace std; int main(){ int t,p,r,a[10],k[10],count[10],i,delivered,n;; scanf("%d",&t); long duration; while(t--) { delivered=0; for(i=1;i<9;++i) { a[i]=0; k[i]=i; count[i]=2; } scanf("%d%d",&p,&n); for(i=1;i<=n;++i) { scanf("%d",&r); a[r]++; } duration=0; while(delivered<p) { duration++; for(i=1;i<9;++i) { if(a[i]==0) continue; if(duration==(k[i])) { delivered+=a[i]; k[i]=duration+i*count[i]; count[i]++; } if(delivered>=p) break; } } printf("%ld\n",duration); } return 0; } |
-
upload with new input
-
result: Success time: 0.01s memory: 2728 kB returned value: 0
1 5 2 1 2
6
-
result: Success time: 0.01s memory: 2728 kB returned value: 0
1 5 1 2
30
-
result: Success time: 0.01s memory: 2728 kB returned value: 0
1 6 1 1
21
-
result: Success time: 0.02s memory: 2728 kB returned value: 0
3 10 4 1 2 3 4 8 1 1 8 8 1 1 1 1 1 1 1 1
12 36 1



