답안 #492470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
492470 2021-12-07T13:11:06 Z vulpes Coins (BOI06_coins) C++17
100 / 100
90 ms 4584 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k; scanf("%d%d", &n, &k);
    vector<int> c(n + 1, k), d(n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &c[i], &d[i]);
    }
    int s = 0, x = 0;
    for (int i = 0; i < n; i++) {
        if (!d[i] && c[i] + s < c[i + 1]) {
            x++; s += c[i];
        }
    }
    s = max(s, 1);
    cout << x << endl << k - s << endl;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:5:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     int n, k; scanf("%d%d", &n, &k);
      |               ~~~~~^~~~~~~~~~~~~~~~
coins.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         scanf("%d%d", &c[i], &d[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 77 ms 4576 KB Output is correct
8 Correct 85 ms 4496 KB Output is correct
9 Correct 90 ms 4584 KB Output is correct
10 Correct 80 ms 4564 KB Output is correct