Submission #749482

# Submission time Handle Problem Language Result Execution time Memory
749482 2023-05-28T05:37:01 Z 반딧불(#9967) Gym Badges (NOI22_gymbadges) C++17
42 / 100
2000 ms 4148 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
pair<int, int> arr[500002];
int DP[5002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%d", &arr[i].first);
    for(int i=1; i<=n; i++) scanf("%d", &arr[i].second);
    sort(arr+1, arr+n+1, [&](pair<int, int> A, pair<int, int> B){
        if(A.first + A.second != B.first + B.second) return A.first + A.second < B.first + B.second;
        return A.second < B.second;
    });

    for(int i=1; i<=n+1; i++) DP[i] = 2e9;
    for(int i=1; i<=n; i++){
        for(int j=i-1; j>=0; j--){
            if(DP[j] <= arr[i].second) DP[j+1] = min(DP[j+1], DP[j] + arr[i].first);
        }
    }

    int ans = 0;
    while(DP[ans+1] < 2e9) ans++;
    printf("%d", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:13:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=1; i<=n; i++) scanf("%d", &arr[i].first);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(int i=1; i<=n; i++) scanf("%d", &arr[i].second);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 4148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 10 ms 340 KB Output is correct
22 Correct 11 ms 456 KB Output is correct
23 Correct 10 ms 420 KB Output is correct
24 Correct 10 ms 452 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 11 ms 340 KB Output is correct
27 Correct 11 ms 448 KB Output is correct
28 Correct 12 ms 456 KB Output is correct
29 Correct 12 ms 448 KB Output is correct
30 Correct 13 ms 456 KB Output is correct
31 Correct 12 ms 340 KB Output is correct
32 Correct 11 ms 340 KB Output is correct
33 Correct 12 ms 340 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 11 ms 340 KB Output is correct
36 Correct 13 ms 340 KB Output is correct
37 Correct 13 ms 332 KB Output is correct
38 Correct 12 ms 452 KB Output is correct
39 Correct 12 ms 336 KB Output is correct
40 Correct 12 ms 444 KB Output is correct
41 Correct 13 ms 452 KB Output is correct
42 Correct 12 ms 420 KB Output is correct
43 Correct 12 ms 444 KB Output is correct
44 Correct 19 ms 340 KB Output is correct
45 Correct 12 ms 424 KB Output is correct
46 Correct 13 ms 340 KB Output is correct
47 Correct 13 ms 340 KB Output is correct
48 Correct 13 ms 468 KB Output is correct
49 Correct 13 ms 416 KB Output is correct
50 Correct 13 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Execution timed out 2093 ms 4148 KB Time limit exceeded
22 Halted 0 ms 0 KB -