Submission #1015723

# Submission time Handle Problem Language Result Execution time Memory
1015723 2024-07-06T17:03:47 Z ByeWorld Gym Badges (NOI22_gymbadges) C++14
100 / 100
288 ms 31148 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define ll long long
#define int long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)/2)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii, int> ipii;
const int MAXN = 5e5+10;
const int MAXA = 1e6+10;
const int INF = 1e18+10;
const int INF2 = 1e18+10;
const int LOG = 19;
const int MOD = 1e9+7;
const int SQRT = 450;
const vector<int> NOL = {};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};
void chmn(int &a, int b){ a = min(a, b); }

int n;
pii a[MAXN];
int dp[MAXN];

signed main(){
    vector <pii> vec;
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i].se;
    for(int i=1; i<=n; i++){ cin >> a[i].fi; vec.pb({a[i].fi+a[i].se, i}); }
    vec.pb({-1, -1});
    sort(vec.begin(), vec.end());

    priority_queue <int> pq;
    int tot = 0;

    for(int i=1; i<=n; i++){
        int idx = vec[i].se;
        // cout << idx << ' ' << tot << " pp\n";
        if(tot <= a[idx].fi){
            tot += a[idx].se; pq.push(a[idx].se);
        } else {
            if(pq.top() > a[idx].se){
                tot -= pq.top(); pq.pop();
                tot += a[idx].se; pq.push(a[idx].se);
            }
        }
    }
    cout << pq.size() << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 270 ms 25324 KB Output is correct
2 Correct 275 ms 25260 KB Output is correct
3 Correct 268 ms 25556 KB Output is correct
4 Correct 278 ms 25236 KB Output is correct
5 Correct 280 ms 25260 KB Output is correct
6 Correct 243 ms 24744 KB Output is correct
7 Correct 245 ms 23844 KB Output is correct
8 Correct 244 ms 24472 KB Output is correct
9 Correct 242 ms 24752 KB Output is correct
10 Correct 246 ms 24640 KB Output is correct
11 Correct 235 ms 27052 KB Output is correct
12 Correct 249 ms 29528 KB Output is correct
13 Correct 245 ms 27308 KB Output is correct
14 Correct 241 ms 29356 KB Output is correct
15 Correct 245 ms 29512 KB Output is correct
16 Correct 250 ms 25256 KB Output is correct
17 Correct 238 ms 25764 KB Output is correct
18 Correct 252 ms 25704 KB Output is correct
19 Correct 222 ms 24744 KB Output is correct
20 Correct 241 ms 24472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 600 KB Output is correct
22 Correct 3 ms 680 KB Output is correct
23 Correct 4 ms 740 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 3 ms 832 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 764 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 3 ms 600 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 600 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 3 ms 832 KB Output is correct
36 Correct 3 ms 604 KB Output is correct
37 Correct 3 ms 740 KB Output is correct
38 Correct 3 ms 676 KB Output is correct
39 Correct 3 ms 604 KB Output is correct
40 Correct 3 ms 604 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 3 ms 600 KB Output is correct
43 Correct 3 ms 604 KB Output is correct
44 Correct 3 ms 684 KB Output is correct
45 Correct 3 ms 604 KB Output is correct
46 Correct 3 ms 680 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 3 ms 712 KB Output is correct
49 Correct 3 ms 600 KB Output is correct
50 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 270 ms 25324 KB Output is correct
22 Correct 275 ms 25260 KB Output is correct
23 Correct 268 ms 25556 KB Output is correct
24 Correct 278 ms 25236 KB Output is correct
25 Correct 280 ms 25260 KB Output is correct
26 Correct 243 ms 24744 KB Output is correct
27 Correct 245 ms 23844 KB Output is correct
28 Correct 244 ms 24472 KB Output is correct
29 Correct 242 ms 24752 KB Output is correct
30 Correct 246 ms 24640 KB Output is correct
31 Correct 235 ms 27052 KB Output is correct
32 Correct 249 ms 29528 KB Output is correct
33 Correct 245 ms 27308 KB Output is correct
34 Correct 241 ms 29356 KB Output is correct
35 Correct 245 ms 29512 KB Output is correct
36 Correct 250 ms 25256 KB Output is correct
37 Correct 238 ms 25764 KB Output is correct
38 Correct 252 ms 25704 KB Output is correct
39 Correct 222 ms 24744 KB Output is correct
40 Correct 241 ms 24472 KB Output is correct
41 Correct 3 ms 600 KB Output is correct
42 Correct 3 ms 680 KB Output is correct
43 Correct 4 ms 740 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 3 ms 832 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 3 ms 764 KB Output is correct
48 Correct 3 ms 604 KB Output is correct
49 Correct 3 ms 604 KB Output is correct
50 Correct 3 ms 600 KB Output is correct
51 Correct 3 ms 604 KB Output is correct
52 Correct 3 ms 724 KB Output is correct
53 Correct 3 ms 600 KB Output is correct
54 Correct 3 ms 604 KB Output is correct
55 Correct 3 ms 832 KB Output is correct
56 Correct 3 ms 604 KB Output is correct
57 Correct 3 ms 740 KB Output is correct
58 Correct 3 ms 676 KB Output is correct
59 Correct 3 ms 604 KB Output is correct
60 Correct 3 ms 604 KB Output is correct
61 Correct 3 ms 636 KB Output is correct
62 Correct 3 ms 600 KB Output is correct
63 Correct 3 ms 604 KB Output is correct
64 Correct 3 ms 684 KB Output is correct
65 Correct 3 ms 604 KB Output is correct
66 Correct 3 ms 680 KB Output is correct
67 Correct 3 ms 604 KB Output is correct
68 Correct 3 ms 712 KB Output is correct
69 Correct 3 ms 600 KB Output is correct
70 Correct 3 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 256 ms 25556 KB Output is correct
74 Correct 245 ms 25516 KB Output is correct
75 Correct 264 ms 25512 KB Output is correct
76 Correct 254 ms 25516 KB Output is correct
77 Correct 256 ms 25516 KB Output is correct
78 Correct 260 ms 26724 KB Output is correct
79 Correct 253 ms 26792 KB Output is correct
80 Correct 284 ms 26812 KB Output is correct
81 Correct 288 ms 26812 KB Output is correct
82 Correct 243 ms 26652 KB Output is correct
83 Correct 247 ms 28076 KB Output is correct
84 Correct 240 ms 28012 KB Output is correct
85 Correct 264 ms 28224 KB Output is correct
86 Correct 248 ms 28076 KB Output is correct
87 Correct 271 ms 28072 KB Output is correct
88 Correct 255 ms 30696 KB Output is correct
89 Correct 249 ms 30608 KB Output is correct
90 Correct 250 ms 30536 KB Output is correct
91 Correct 243 ms 30632 KB Output is correct
92 Correct 244 ms 30668 KB Output is correct
93 Correct 254 ms 30784 KB Output is correct
94 Correct 244 ms 30892 KB Output is correct
95 Correct 227 ms 30832 KB Output is correct
96 Correct 254 ms 30672 KB Output is correct
97 Correct 232 ms 30892 KB Output is correct
98 Correct 249 ms 25764 KB Output is correct
99 Correct 274 ms 25772 KB Output is correct
100 Correct 268 ms 25768 KB Output is correct
101 Correct 234 ms 31148 KB Output is correct
102 Correct 236 ms 31148 KB Output is correct