Submission #572852

#TimeUsernameProblemLanguageResultExecution timeMemory
572852denniskimCoins (BOI06_coins)C++17
100 / 100
108 ms8076 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define MAX 9223372036854775807LL #define MIN -9223372036854775807LL #define INF 0x3f3f3f3f3f3f3f3f #define fi first #define se second ll n, k; pair<ll, ll> a[500010]; ll ans1, ans2; int main(void) { scanf("%lld %lld", &n, &k); for(ll i = 1 ; i <= n ; i++) scanf("%lld %lld", &a[i].fi, &a[i].se); a[n + 1].fi = MAX; for(ll i = 1 ; i <= n ; i++) { if(a[i].se) continue; if(ans1 + a[i].fi < min(a[i + 1].fi, k)) { ans1 += a[i].fi; ans2++; } } if(!ans1) ans1 = 1; printf("%lld\n%lld", ans2, k - ans1); return 0; }

Compilation message (stderr)

coins.cpp: In function 'int main()':
coins.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%lld %lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
coins.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%lld %lld", &a[i].fi, &a[i].se);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...