Submission #969087

# Submission time Handle Problem Language Result Execution time Memory
969087 2024-04-24T13:26:52 Z TrendBattles Gym Badges (NOI22_gymbadges) C++14
0 / 100
115 ms 15744 KB
//https://oj.uz/problem/view/NOI22_gymbadges
#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;

#define INFILE "NOI22_gymbadges.inp"
#define OUTFILE "NOI22_gymbadges.out"
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen(INFILE, "r")) {
        freopen(INFILE, "r", stdin);
        freopen(OUTFILE, "w", stdout);
    }
    
    int N; cin >> N;
    vector <int> X(N), L(N);
    for (int& v : X) cin >> v;
    for (int& v : L) cin >> v;

    vector <int> order(N); iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&] (int u, int v) {
        return L[u] < L[v];
    });

    int max_participated = 0;
    priority_queue <int> heap; lli sum = 0;
    for (int i = 0; i < N; ++i) {
        while (sum > L[order[i]]) {
            sum -= heap.top();
            heap.pop();
        }

        heap.emplace(X[order[i]]);
        sum += X[order[i]];
        
        max_participated = max(max_participated, (int) heap.size());
    }

    cout << max_participated;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen(INFILE, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(OUTFILE, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 96 ms 15368 KB Output is correct
2 Correct 104 ms 15368 KB Output is correct
3 Correct 100 ms 15568 KB Output is correct
4 Correct 95 ms 15360 KB Output is correct
5 Correct 97 ms 15440 KB Output is correct
6 Correct 97 ms 14736 KB Output is correct
7 Correct 90 ms 13908 KB Output is correct
8 Correct 101 ms 14464 KB Output is correct
9 Correct 98 ms 14676 KB Output is correct
10 Correct 100 ms 14676 KB Output is correct
11 Correct 115 ms 14544 KB Output is correct
12 Incorrect 107 ms 15744 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -