Submission #991925

# Submission time Handle Problem Language Result Execution time Memory
991925 2024-06-03T12:14:59 Z KK_1729 Gym Badges (NOI22_gymbadges) C++17
15 / 100
438 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()

void printVector(vector<int> a){
    for (auto x: a) cout << x << " ";
    cout << endl;
}

bool comp(pair<int, int> x, pair<int, int> y){
    return x.first+x.second < y.first+y.second;
}
void solve(){
    
    int n; cin >> n;
    vector<int> x(n), l(n);
    FOR(i,0,n) cin >> x[i];
    FOR(i,0,n) cin >> l[i];
    
    vector<pair<int, int>> o = {{}};
    FOR(i,0,n) o.pb({x[i], l[i]});
    sort(all(o), comp);
    
    vector<vector<int>> dp(n+1, vector<int>(n+1, 1e15));
    dp[0][0] = 0;
    FOR(i,1,n+1){
        FOR(j,1,i+1){
            dp[i][j] = dp[i-1][j];
            if (dp[i-1][j-1] <= o[i].second) dp[i][j] = min(dp[i][j], dp[i-1][j-1]+o[i].first);
        }
    }
    int ans = 0;
    FOR(i,1,n+1){
        if (dp[n][i] < 1e14) ans = max(ans, i);
    }
    // printVector(dp[n]);
    cout << ans << endl;
}
int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int t = 1; // cin >> t;
    while (t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 438 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 96 ms 190388 KB Output is correct
22 Correct 95 ms 193364 KB Output is correct
23 Correct 86 ms 191828 KB Output is correct
24 Correct 90 ms 192532 KB Output is correct
25 Correct 84 ms 192412 KB Output is correct
26 Correct 86 ms 190220 KB Output is correct
27 Correct 89 ms 194680 KB Output is correct
28 Correct 85 ms 188796 KB Output is correct
29 Correct 89 ms 192704 KB Output is correct
30 Correct 86 ms 195924 KB Output is correct
31 Correct 88 ms 195412 KB Output is correct
32 Incorrect 84 ms 190068 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Runtime error 438 ms 1048576 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -