Submission #952376

#TimeUsernameProblemLanguageResultExecution timeMemory
952376IskachunCoins (BOI06_coins)C++17
0 / 100
1096 ms8284 KiB
#include <iostream> #include <vector> using namespace std; typedef long long ll; vector<ll> a, vis; ll n; ll f(ll x) { ll cnt = 0; for (ll i = n - 1; i >= 0; i--) { if (x >= a[i] and vis[i] == 0) cnt++; while (x >= a[i]) x -= a[i]; } return cnt; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll k; cin >> n >> k; a.resize(n), vis.resize(n); for (ll i = 0; i < n; i++) cin >> a[i] >> vis[i]; ll cnt = 0, ans = 0; for (ll l = k - 1; l >= 1; l--) { //cout << l << ' '; ll x = f(l); if (x > cnt) cnt = x, ans = l; } cout << cnt << '\n' << k - ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...