| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 952374 | Iskachun | Coins (BOI06_coins) | C++17 | 66 ms | 14336 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<int> a, vis;
int n;
int f(int x) {
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (x >= a[i] and vis[a[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);
    int k; cin >> n >> k;
    a.resize(n), vis.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> vis[i];
    int cnt = 0, ans = 0;
    for (int l = k - 1; l >= 1; l--) {
        //cout << l << ' ';
        int x = f(l);
        if (x > cnt) cnt = x, ans = l;
    }
    cout << cnt << '\n' << k - ans;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
