답안 #1091071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091071 2024-09-19T16:47:08 Z pokmui9909 스트랩 (JOI14_straps) C++17
100 / 100
29 ms 32088 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define x first
#define y second

ll N; 
pair<ll, ll> A[2005];
ll D[2005][2005];

void chmax(ll &k, ll v){
    k = max(k, v);
}

int main(){
    cin.tie(0) -> sync_with_stdio(0);

    cin >> N;
    for(ll i = 1; i <= N; i++){
        cin >> A[i].x >> A[i].y;
    }
    sort(A + 1, A + N + 1, greater<pair<ll, ll>>());
    fill(D[0], D[2004] + 2005, -1e18);
    D[0][1] = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j <= N; j++){
            chmax(D[i + 1][j], D[i][j]);
            if(j >= 1) chmax(D[i + 1][min(N, j - 1 + A[i + 1].x)], D[i][j] + A[i + 1].y);
        }
    }
    cout << *max_element(D[N], D[N] + N + 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31832 KB Output is correct
2 Correct 13 ms 31836 KB Output is correct
3 Correct 13 ms 31788 KB Output is correct
4 Correct 13 ms 31836 KB Output is correct
5 Correct 13 ms 31836 KB Output is correct
6 Correct 13 ms 31836 KB Output is correct
7 Correct 14 ms 31836 KB Output is correct
8 Correct 13 ms 31836 KB Output is correct
9 Correct 13 ms 31788 KB Output is correct
10 Correct 13 ms 31832 KB Output is correct
11 Correct 14 ms 31836 KB Output is correct
12 Correct 16 ms 31832 KB Output is correct
13 Correct 14 ms 31724 KB Output is correct
14 Correct 13 ms 31836 KB Output is correct
15 Correct 13 ms 31836 KB Output is correct
16 Correct 13 ms 31944 KB Output is correct
17 Correct 12 ms 31772 KB Output is correct
18 Correct 12 ms 31832 KB Output is correct
19 Correct 14 ms 31828 KB Output is correct
20 Correct 13 ms 31836 KB Output is correct
21 Correct 12 ms 31832 KB Output is correct
22 Correct 13 ms 31896 KB Output is correct
23 Correct 13 ms 31832 KB Output is correct
24 Correct 13 ms 31688 KB Output is correct
25 Correct 13 ms 31836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31836 KB Output is correct
2 Correct 13 ms 31836 KB Output is correct
3 Correct 13 ms 31836 KB Output is correct
4 Correct 12 ms 31840 KB Output is correct
5 Correct 14 ms 31696 KB Output is correct
6 Correct 13 ms 31836 KB Output is correct
7 Correct 14 ms 31700 KB Output is correct
8 Correct 15 ms 31832 KB Output is correct
9 Correct 14 ms 31836 KB Output is correct
10 Correct 15 ms 31836 KB Output is correct
11 Correct 16 ms 31836 KB Output is correct
12 Correct 22 ms 31972 KB Output is correct
13 Correct 21 ms 31836 KB Output is correct
14 Correct 29 ms 31884 KB Output is correct
15 Correct 22 ms 31832 KB Output is correct
16 Correct 22 ms 31836 KB Output is correct
17 Correct 22 ms 31832 KB Output is correct
18 Correct 21 ms 31876 KB Output is correct
19 Correct 22 ms 31980 KB Output is correct
20 Correct 23 ms 31836 KB Output is correct
21 Correct 20 ms 31836 KB Output is correct
22 Correct 20 ms 31736 KB Output is correct
23 Correct 20 ms 31836 KB Output is correct
24 Correct 19 ms 31828 KB Output is correct
25 Correct 23 ms 31852 KB Output is correct
26 Correct 22 ms 31832 KB Output is correct
27 Correct 20 ms 31976 KB Output is correct
28 Correct 19 ms 31864 KB Output is correct
29 Correct 20 ms 31836 KB Output is correct
30 Correct 23 ms 31836 KB Output is correct
31 Correct 21 ms 31764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31684 KB Output is correct
2 Correct 15 ms 31840 KB Output is correct
3 Correct 14 ms 31832 KB Output is correct
4 Correct 14 ms 31796 KB Output is correct
5 Correct 17 ms 31836 KB Output is correct
6 Correct 13 ms 31836 KB Output is correct
7 Correct 13 ms 31836 KB Output is correct
8 Correct 14 ms 31860 KB Output is correct
9 Correct 16 ms 31716 KB Output is correct
10 Correct 16 ms 31836 KB Output is correct
11 Correct 16 ms 31836 KB Output is correct
12 Correct 15 ms 31952 KB Output is correct
13 Correct 16 ms 31836 KB Output is correct
14 Correct 15 ms 31832 KB Output is correct
15 Correct 18 ms 31832 KB Output is correct
16 Correct 16 ms 31836 KB Output is correct
17 Correct 21 ms 31840 KB Output is correct
18 Correct 21 ms 31832 KB Output is correct
19 Correct 19 ms 31836 KB Output is correct
20 Correct 18 ms 31836 KB Output is correct
21 Correct 19 ms 31984 KB Output is correct
22 Correct 19 ms 31836 KB Output is correct
23 Correct 19 ms 31840 KB Output is correct
24 Correct 20 ms 31984 KB Output is correct
25 Correct 22 ms 31728 KB Output is correct
26 Correct 24 ms 31912 KB Output is correct
27 Correct 24 ms 31876 KB Output is correct
28 Correct 20 ms 31844 KB Output is correct
29 Correct 22 ms 31872 KB Output is correct
30 Correct 21 ms 31840 KB Output is correct
31 Correct 19 ms 31836 KB Output is correct
32 Correct 21 ms 31832 KB Output is correct
33 Correct 21 ms 31836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 31836 KB Output is correct
2 Correct 23 ms 31836 KB Output is correct
3 Correct 21 ms 31836 KB Output is correct
4 Correct 21 ms 31832 KB Output is correct
5 Correct 22 ms 31836 KB Output is correct
6 Correct 22 ms 31836 KB Output is correct
7 Correct 20 ms 31732 KB Output is correct
8 Correct 20 ms 31832 KB Output is correct
9 Correct 20 ms 31972 KB Output is correct
10 Correct 22 ms 32088 KB Output is correct
11 Correct 21 ms 31836 KB Output is correct
12 Correct 20 ms 31836 KB Output is correct
13 Correct 25 ms 31836 KB Output is correct
14 Correct 23 ms 31832 KB Output is correct
15 Correct 21 ms 31832 KB Output is correct
16 Correct 21 ms 31836 KB Output is correct
17 Correct 19 ms 31836 KB Output is correct
18 Correct 21 ms 31836 KB Output is correct
19 Correct 21 ms 31984 KB Output is correct
20 Correct 21 ms 31960 KB Output is correct
21 Correct 21 ms 31960 KB Output is correct
22 Correct 20 ms 31812 KB Output is correct
23 Correct 23 ms 31832 KB Output is correct
24 Correct 20 ms 31836 KB Output is correct
25 Correct 21 ms 31976 KB Output is correct