Submission #757990

# Submission time Handle Problem Language Result Execution time Memory
757990 2023-06-14T04:15:22 Z Dexva Gym Badges (NOI22_gymbadges) C++14
0 / 100
2000 ms 16452 KB
#include <bits/stdc++.h>
using namespace std;

#define lln long long

void solve() {
    lln n; cin >> n;
    lln gain[n], cap[n];
    for (lln i=0;i<n;i++) cin >> gain[i];
    for (lln i=0;i<n;i++) cin >> cap[i];

    lln ans = 0;
    vector<pair<lln,lln> > gyms; //gain, cap
    for (lln i=0;i<n;i++) gyms.push_back(make_pair(gain[i], cap[i]));

    sort(gyms.begin(),gyms.end());

    // for (lln i=0;i<n;i++) cout << get<0>(gyms[i]) << " " << get<1>(gyms[i]) << '\n';

    for (lln t=0;t<n;t++) {
        lln level = 0, badges = 0; 
        for (lln i=0;i<n;i++) {
            if (i==t) continue;
            // cout << t << " " << i << " " << level << '\n';
            if ((level+get<0>(gyms[i])) <= get<1>(gyms[t]) && level <= get<1>(gyms[i])) {
                // cout << "yes " << i << " " << t << '\n';
                level += get<0>(gyms[i]);
                badges++;
            }
        } 
        // cout << t << " " << badges << '\n';
        ans = max(ans, badges+1);
    } 

    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 16452 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 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -