답안 #757962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757962 2023-06-14T02:55:23 Z roCatalyst Gym Badges (NOI22_gymbadges) C++14
9 / 100
418 ms 5500 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int N;
    cin >> N;

    vector<int> X;
    for (int i = 0; i < N; i++) {
        int Xi;
        cin >> Xi;
        X.push_back(Xi);
    }

    vector<int> L;
    for (int i = 0; i < N; i++) {
        int Li;
        cin >> Li;
        L.push_back(Li);
    }

    

    if (N > 10) {
        int ans = 0;
        sort(X.begin(),X.end());
        ll currLevel = 0;
        ll cap = L.back();

        vector<int>::iterator p = X.begin();
        while ((currLevel <= cap)&&(p!=X.end())) {
            ans++;
            currLevel += *p;
            p++;
        }

        cout << ans << endl;
    } else {
        int ans = 0;
        vector<pair<int,int>> pq; 
       
        
        for (int i = 0; i < N; i++) {
            pq.push_back(make_pair(X[i],L[i]));
        }
        sort(pq.begin(),pq.end());

        for(int i = 0; i < N; i++) {
            int currAns = 0;
            ll currLevel = 0;

            for (int j = i; j < N; j++) {
                if (currLevel > pq[j].second) {
                    j++;
                } else {
                    currAns++;
                    currLevel += pq[j].first;
                }
            }
            ans = max(ans,currAns);
        }

        cout << ans << endl;
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 416 ms 5468 KB Output is correct
2 Correct 386 ms 5360 KB Output is correct
3 Correct 392 ms 5472 KB Output is correct
4 Correct 418 ms 5440 KB Output is correct
5 Correct 388 ms 5312 KB Output is correct
6 Correct 360 ms 5432 KB Output is correct
7 Correct 346 ms 5424 KB Output is correct
8 Correct 363 ms 5496 KB Output is correct
9 Correct 359 ms 5376 KB Output is correct
10 Correct 356 ms 5244 KB Output is correct
11 Correct 328 ms 5388 KB Output is correct
12 Correct 315 ms 5428 KB Output is correct
13 Correct 378 ms 5276 KB Output is correct
14 Correct 318 ms 5428 KB Output is correct
15 Correct 322 ms 5404 KB Output is correct
16 Correct 346 ms 5420 KB Output is correct
17 Correct 353 ms 5208 KB Output is correct
18 Correct 336 ms 5436 KB Output is correct
19 Correct 346 ms 5344 KB Output is correct
20 Correct 357 ms 5500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -