# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
137905 | 2019-07-28T13:45:19 Z | onjo0127 | Coins (BOI06_coins) | C++11 | 134 ms | 12024 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 252 KB | Output is correct |
7 | Correct | 107 ms | 11896 KB | Output is correct |
8 | Correct | 107 ms | 11868 KB | Output is correct |
9 | Correct | 122 ms | 12024 KB | Output is correct |
10 | Correct | 134 ms | 11768 KB | Output is correct |