Submission #802862

# Submission time Handle Problem Language Result Execution time Memory
802862 2023-08-02T15:15:50 Z Theo830 Gym Badges (NOI22_gymbadges) C++17
100 / 100
496 ms 46456 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define ii pair<ll,ll>
#define F first
#define S second
int main(){
    ll n;
    cin>>n;
    ll a[n],b[n];
    f(i,0,n){
        cin>>a[i];
    }
    f(i,0,n){
        cin>>b[i];
    }
    vector<ii>arr;
    f(i,0,n){
        arr.pb(ii(a[i]+b[i],a[i]));
    }
    sort(arr.begin(),arr.end());
    ll sum = 0;
    multiset<ll>ex;
    f(i,0,n){
        if(sum + arr[i].S <= arr[i].F){
            sum += arr[i].S;
            ex.insert(arr[i].S);
        }
        else{
            sum += arr[i].S;
            ex.insert(arr[i].S);
            auto it = ex.rbegin();
            sum -= (*it);
            ex.erase(ex.find((*it)));
        }
    }
    cout<<ex.size()<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 348 ms 25580 KB Output is correct
2 Correct 352 ms 25720 KB Output is correct
3 Correct 342 ms 25620 KB Output is correct
4 Correct 345 ms 25600 KB Output is correct
5 Correct 363 ms 25656 KB Output is correct
6 Correct 382 ms 25352 KB Output is correct
7 Correct 341 ms 24220 KB Output is correct
8 Correct 380 ms 24820 KB Output is correct
9 Correct 363 ms 25072 KB Output is correct
10 Correct 375 ms 25708 KB Output is correct
11 Correct 407 ms 33752 KB Output is correct
12 Correct 420 ms 35688 KB Output is correct
13 Correct 401 ms 35104 KB Output is correct
14 Correct 440 ms 35600 KB Output is correct
15 Correct 370 ms 36536 KB Output is correct
16 Correct 388 ms 26860 KB Output is correct
17 Correct 378 ms 27652 KB Output is correct
18 Correct 369 ms 28216 KB Output is correct
19 Correct 365 ms 26352 KB Output is correct
20 Correct 367 ms 25260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 596 KB Output is correct
22 Correct 4 ms 596 KB Output is correct
23 Correct 4 ms 568 KB Output is correct
24 Correct 4 ms 592 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 4 ms 596 KB Output is correct
27 Correct 4 ms 568 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 4 ms 596 KB Output is correct
30 Correct 4 ms 564 KB Output is correct
31 Correct 5 ms 596 KB Output is correct
32 Correct 4 ms 596 KB Output is correct
33 Correct 4 ms 596 KB Output is correct
34 Correct 4 ms 568 KB Output is correct
35 Correct 4 ms 596 KB Output is correct
36 Correct 4 ms 584 KB Output is correct
37 Correct 4 ms 596 KB Output is correct
38 Correct 4 ms 596 KB Output is correct
39 Correct 4 ms 696 KB Output is correct
40 Correct 4 ms 696 KB Output is correct
41 Correct 4 ms 724 KB Output is correct
42 Correct 4 ms 724 KB Output is correct
43 Correct 4 ms 724 KB Output is correct
44 Correct 4 ms 724 KB Output is correct
45 Correct 4 ms 724 KB Output is correct
46 Correct 4 ms 716 KB Output is correct
47 Correct 4 ms 696 KB Output is correct
48 Correct 4 ms 692 KB Output is correct
49 Correct 4 ms 692 KB Output is correct
50 Correct 5 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 348 ms 25580 KB Output is correct
22 Correct 352 ms 25720 KB Output is correct
23 Correct 342 ms 25620 KB Output is correct
24 Correct 345 ms 25600 KB Output is correct
25 Correct 363 ms 25656 KB Output is correct
26 Correct 382 ms 25352 KB Output is correct
27 Correct 341 ms 24220 KB Output is correct
28 Correct 380 ms 24820 KB Output is correct
29 Correct 363 ms 25072 KB Output is correct
30 Correct 375 ms 25708 KB Output is correct
31 Correct 407 ms 33752 KB Output is correct
32 Correct 420 ms 35688 KB Output is correct
33 Correct 401 ms 35104 KB Output is correct
34 Correct 440 ms 35600 KB Output is correct
35 Correct 370 ms 36536 KB Output is correct
36 Correct 388 ms 26860 KB Output is correct
37 Correct 378 ms 27652 KB Output is correct
38 Correct 369 ms 28216 KB Output is correct
39 Correct 365 ms 26352 KB Output is correct
40 Correct 367 ms 25260 KB Output is correct
41 Correct 3 ms 596 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 4 ms 568 KB Output is correct
44 Correct 4 ms 592 KB Output is correct
45 Correct 4 ms 592 KB Output is correct
46 Correct 4 ms 596 KB Output is correct
47 Correct 4 ms 568 KB Output is correct
48 Correct 4 ms 596 KB Output is correct
49 Correct 4 ms 596 KB Output is correct
50 Correct 4 ms 564 KB Output is correct
51 Correct 5 ms 596 KB Output is correct
52 Correct 4 ms 596 KB Output is correct
53 Correct 4 ms 596 KB Output is correct
54 Correct 4 ms 568 KB Output is correct
55 Correct 4 ms 596 KB Output is correct
56 Correct 4 ms 584 KB Output is correct
57 Correct 4 ms 596 KB Output is correct
58 Correct 4 ms 596 KB Output is correct
59 Correct 4 ms 696 KB Output is correct
60 Correct 4 ms 696 KB Output is correct
61 Correct 4 ms 724 KB Output is correct
62 Correct 4 ms 724 KB Output is correct
63 Correct 4 ms 724 KB Output is correct
64 Correct 4 ms 724 KB Output is correct
65 Correct 4 ms 724 KB Output is correct
66 Correct 4 ms 716 KB Output is correct
67 Correct 4 ms 696 KB Output is correct
68 Correct 4 ms 692 KB Output is correct
69 Correct 4 ms 692 KB Output is correct
70 Correct 5 ms 724 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 0 ms 296 KB Output is correct
73 Correct 335 ms 25728 KB Output is correct
74 Correct 347 ms 25740 KB Output is correct
75 Correct 335 ms 25748 KB Output is correct
76 Correct 336 ms 25812 KB Output is correct
77 Correct 333 ms 25752 KB Output is correct
78 Correct 346 ms 28528 KB Output is correct
79 Correct 347 ms 28592 KB Output is correct
80 Correct 344 ms 28472 KB Output is correct
81 Correct 366 ms 28568 KB Output is correct
82 Correct 337 ms 28512 KB Output is correct
83 Correct 366 ms 33900 KB Output is correct
84 Correct 355 ms 33828 KB Output is correct
85 Correct 372 ms 33956 KB Output is correct
86 Correct 367 ms 33880 KB Output is correct
87 Correct 373 ms 33828 KB Output is correct
88 Correct 397 ms 39148 KB Output is correct
89 Correct 404 ms 39016 KB Output is correct
90 Correct 419 ms 39036 KB Output is correct
91 Correct 420 ms 39036 KB Output is correct
92 Correct 411 ms 39144 KB Output is correct
93 Correct 438 ms 42336 KB Output is correct
94 Correct 425 ms 42232 KB Output is correct
95 Correct 450 ms 42240 KB Output is correct
96 Correct 423 ms 42236 KB Output is correct
97 Correct 443 ms 42236 KB Output is correct
98 Correct 339 ms 26240 KB Output is correct
99 Correct 338 ms 26096 KB Output is correct
100 Correct 338 ms 26240 KB Output is correct
101 Correct 496 ms 46456 KB Output is correct
102 Correct 473 ms 46376 KB Output is correct