답안 #749551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749551 2023-05-28T07:52:53 Z 반딧불(#9967) Gym Badges (NOI22_gymbadges) C++17
9 / 100
178 ms 13528 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;
    int S = 0;
    for(int i=1; i<=n; i++){
        if(S > arr[1].second) break;
        S += arr[i].first, 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);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 4288 KB Output is correct
2 Correct 152 ms 13528 KB Output is correct
3 Correct 158 ms 13360 KB Output is correct
4 Correct 157 ms 13344 KB Output is correct
5 Correct 157 ms 13416 KB Output is correct
6 Correct 171 ms 12504 KB Output is correct
7 Correct 170 ms 11932 KB Output is correct
8 Correct 169 ms 12384 KB Output is correct
9 Correct 163 ms 12416 KB Output is correct
10 Correct 150 ms 12428 KB Output is correct
11 Correct 148 ms 11468 KB Output is correct
12 Correct 160 ms 11404 KB Output is correct
13 Correct 158 ms 11464 KB Output is correct
14 Correct 156 ms 11484 KB Output is correct
15 Correct 178 ms 11476 KB Output is correct
16 Correct 162 ms 11840 KB Output is correct
17 Correct 149 ms 11852 KB Output is correct
18 Correct 162 ms 11964 KB Output is correct
19 Correct 171 ms 11944 KB Output is correct
20 Correct 164 ms 11932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -