Submission #137905

#TimeUsernameProblemLanguageResultExecution timeMemory
137905onjo0127Coins (BOI06_coins)C++11
100 / 100
134 ms12024 KiB
#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 (stderr)

coins.cpp: In function 'int main()':
coins.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&K);
  ~~~~~^~~~~~~~~~~~~~
coins.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%d",&C[i],&A[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...