Submission #492466

#TimeUsernameProblemLanguageResultExecution timeMemory
492466vulpesCoins (BOI06_coins)C++17
90 / 100
93 ms9964 KiB
#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];
        }
    }
    cout << x << endl << k - s << endl;
}

Compilation message (stderr)

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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...