답안 #749549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749549 2023-05-28T07:49:25 Z 반딧불(#9967) Gym Badges (NOI22_gymbadges) C++17
0 / 100
146 ms 4684 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(ans+1<=n && arr[1].second >= arr[ans+1].first) arr[1].second -= arr[++ans].first;
    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 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 4684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -