답안 #952375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952375 2024-03-23T16:18:34 Z Iskachun Coins (BOI06_coins) C++17
0 / 100
1000 ms 4188 KB
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<int> a, vis;
int n;
int f(ll x) {
    int cnt = 0;
    for (int 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 (int 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 << ' ';
        int x = f(l);
        if (x > cnt) cnt = x, ans = l;
    }
    cout << cnt << '\n' << k - ans;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 348 KB Time limit exceeded
2 Incorrect 4 ms 348 KB Output isn't correct
3 Execution timed out 1090 ms 348 KB Time limit exceeded
4 Execution timed out 1059 ms 348 KB Time limit exceeded
5 Execution timed out 1066 ms 348 KB Time limit exceeded
6 Execution timed out 1063 ms 348 KB Time limit exceeded
7 Execution timed out 1059 ms 4188 KB Time limit exceeded
8 Execution timed out 1092 ms 4184 KB Time limit exceeded
9 Execution timed out 1064 ms 4188 KB Time limit exceeded
10 Execution timed out 1047 ms 4188 KB Time limit exceeded