# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
137553 | 2019-07-28T06:27:35 Z | 김세빈(#3278) | Coins (BOI06_coins) | C++14 | 120 ms | 4228 KB |
#include <bits/stdc++.h> using namespace std; int C[505050], D[505050]; vector <int> V; int n, k, s, v; int main() { int i, r, t; scanf("%d%d", &n, &k); for(i=1; i<=n; i++){ scanf("%d%d", C + i, D + i); if(C[i] >= k) break; } n = i; C[n] = k; D[n] = 1; V.push_back(0); s = 0; for(i=1; i<n; i++){ if(C[i] + C[i] <= C[i + 1]) r = C[i] - 1; else r = (C[i + 1] - 1) % C[i]; if(!D[i] && r >= V[s]){ V.push_back(V[s] + C[i]); s ++; } } printf("%d\n%d\n", s, min(k - 1, k - V[s])); 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 | 256 KB | Output is correct |
7 | Correct | 108 ms | 4216 KB | Output is correct |
8 | Correct | 107 ms | 4216 KB | Output is correct |
9 | Correct | 120 ms | 4228 KB | Output is correct |
10 | Correct | 120 ms | 4216 KB | Output is correct |