Submission #405905

#TimeUsernameProblemLanguageResultExecution timeMemory
405905gs21045Coins (BOI06_coins)C++14
100 / 100
130 ms9960 KiB
#include <bits/stdc++.h> #define sz(v) ((int)(v).size()) using namespace std; typedef long long lint; typedef pair<int, int> pi; int main() { int n, k; scanf("%d %d",&n,&k); vector<pi> v(n + 1); for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second); v[n].first = k; int sum = 0, cnt = 0; for(int i=0; i<n; i++) { if(!v[i].second && sum + v[i].first < v[i+1].first) { sum += v[i].first; cnt++; } } if(sum == 0) sum = 1; cout << cnt << endl << k - sum << endl; }

Compilation message (stderr)

coins.cpp: In function 'int main()':
coins.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  int n, k; scanf("%d %d",&n,&k);
      |            ~~~~~^~~~~~~~~~~~~~~
coins.cpp:10:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...