# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
137905 | onjo0127 | Coins (BOI06_coins) | C++11 | 134 ms | 12024 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int L = 500000000;
int N, K, A[500009];
long long C[500009];
int main() {
scanf("%d%d",&N,&K);
for(int i=1; i<=N; i++) {
scanf("%lld%d",&C[i],&A[i]);
A[i] = 1 - A[i];
} C[N+1] = K;
long long s = 0;
int ans = 0, la = K-1;
for(int i=1; i<=N; i++) {
if(A[i] && C[i] + s < C[i+1]) {
++ans;
la = K - (C[i] + s);
s += C[i];
}
}
printf("%d\n%d", ans, la);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |