Submission #307235

#TimeUsernameProblemLanguageResultExecution timeMemory
307235RainbowbunnyCoins (BOI06_coins)C++17
100 / 100
94 ms9980 KiB
#include <bits/stdc++.h> #define mp make_pair #define eb emplace_back #define fi first #define se second using namespace std; using cd = complex <double>; const long long INF = 1e15; const int N = 3e5 + 2; //const int mod = 1e9 + 7;//998244353;//1e9 + 7;//786433; const double Pi = acos(-1); void Fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int n, k; int cnt, ans; int a[500005], b[500005]; signed main() { Fastio(); cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } a[n + 1] = k; for(int i = 1; i <= n; i++) { if(b[i] == 0 and ans + a[i] < a[i + 1]) { ans += a[i]; cnt++; } } cout << cnt << '\n' << min(k - ans, k - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...