답안 #991951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991951 2024-06-03T12:49:53 Z KK_1729 Gym Badges (NOI22_gymbadges) C++17
42 / 100
435 ms 1048580 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 = {{0, 0}};

    FOR(i,0,n) o.pb({x[i], l[i]});

    sort(all(o), comp);

    

    vector<vector<int>> dp(n+1, vector<int>(n+1, 1e18));

    dp[0][0] = 0;

    FOR(i,1,n+1){
		dp[i][0] = 0;
        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-1][j], dp[i-1][j-1]+o[i].first);
            else dp[i][j] = dp[i-1][j];

        }

    }

    int ans = 0;

    FOR(i,1,n+1){

        if (dp[n][i] < 1e17) 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();

}
# 결과 실행 시간 메모리 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 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 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 344 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 344 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
# 결과 실행 시간 메모리 Grader output
1 Runtime error 435 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 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 344 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 344 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 88 ms 190292 KB Output is correct
22 Correct 99 ms 193220 KB Output is correct
23 Correct 92 ms 191828 KB Output is correct
24 Correct 99 ms 192336 KB Output is correct
25 Correct 89 ms 192212 KB Output is correct
26 Correct 91 ms 190284 KB Output is correct
27 Correct 95 ms 194644 KB Output is correct
28 Correct 93 ms 188752 KB Output is correct
29 Correct 91 ms 192672 KB Output is correct
30 Correct 92 ms 195892 KB Output is correct
31 Correct 89 ms 195420 KB Output is correct
32 Correct 86 ms 190104 KB Output is correct
33 Correct 102 ms 192924 KB Output is correct
34 Correct 96 ms 194644 KB Output is correct
35 Correct 88 ms 193876 KB Output is correct
36 Correct 96 ms 194896 KB Output is correct
37 Correct 93 ms 191024 KB Output is correct
38 Correct 83 ms 189852 KB Output is correct
39 Correct 88 ms 193420 KB Output is correct
40 Correct 93 ms 191056 KB Output is correct
41 Correct 95 ms 194836 KB Output is correct
42 Correct 110 ms 191056 KB Output is correct
43 Correct 87 ms 190800 KB Output is correct
44 Correct 93 ms 193436 KB Output is correct
45 Correct 96 ms 191820 KB Output is correct
46 Correct 89 ms 195668 KB Output is correct
47 Correct 89 ms 192336 KB Output is correct
48 Correct 89 ms 192048 KB Output is correct
49 Correct 91 ms 190292 KB Output is correct
50 Correct 106 ms 192592 KB Output is correct
# 결과 실행 시간 메모리 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 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 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 344 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 344 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 435 ms 1048580 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -