답안 #756119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756119 2023-06-11T07:04:39 Z browntoad Gym Badges (NOI22_gymbadges) C++14
100 / 100
214 ms 14760 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define pip pair<int, pii>
#define pdd pair<double ,double>
#define pcc pair<char, char>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif

const ll inf = 1ll<<60;
const ll iinf = 2147483647;
const ll mod = 1e9+7;
const ll maxn=3e5+5;
const ll maxm=105;
const double PI=acos(-1);

ll pw(ll x, ll p, ll m=mod){
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=m;
        }
        x*=x;
        x%=m;
        p>>=1;
    }
    return ret;
}

ll inv(ll a, ll m=mod){
    return pw(a,m-2,m);
}

bool cmp(pii a, pii b){
	return a.f+a.s < b.f+b.s;
}
int n;
vector<pii> vc;
void inp(){
    cin>>n;
    vc = vector<pii> (n);
    REP(i, n) cin>>vc[i].s;
    REP(i, n) cin>>vc[i].f;
}
int run(){
    sort(ALL(vc), cmp);
    int cnt = 0, ans = 0;
    priority_queue<int> pq;
    REP(i, n){
        cnt += vc[i].s;
        pq.push(vc[i].s);
        while(cnt > vc[i].f+vc[i].s){
            cnt -= pq.top();
            pq.pop();
        }
        ans = max(ans, SZ(pq));
    }
    return ans;
}
int run2(){
    sort(ALL(vc), cmp);
}
signed main(){
    IOS();
    inp();
    cout<<run()<<endl;

}
/*
3
3 4 2
2 1 3
*/

Compilation message

Main.cpp: In function 'long long int run2()':
Main.cpp:83:1: warning: no return statement in function returning non-void [-Wreturn-type]
   83 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 9840 KB Output is correct
2 Correct 176 ms 10100 KB Output is correct
3 Correct 190 ms 10108 KB Output is correct
4 Correct 172 ms 10572 KB Output is correct
5 Correct 185 ms 9216 KB Output is correct
6 Correct 176 ms 11404 KB Output is correct
7 Correct 159 ms 13004 KB Output is correct
8 Correct 171 ms 9292 KB Output is correct
9 Correct 179 ms 9320 KB Output is correct
10 Correct 185 ms 9296 KB Output is correct
11 Correct 164 ms 10840 KB Output is correct
12 Correct 151 ms 13812 KB Output is correct
13 Correct 152 ms 11056 KB Output is correct
14 Correct 153 ms 14584 KB Output is correct
15 Correct 162 ms 14320 KB Output is correct
16 Correct 171 ms 10840 KB Output is correct
17 Correct 178 ms 10180 KB Output is correct
18 Correct 182 ms 10984 KB Output is correct
19 Correct 196 ms 10232 KB Output is correct
20 Correct 192 ms 10988 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 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 524 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 404 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 324 KB Output is correct
28 Correct 2 ms 404 KB Output is correct
29 Correct 2 ms 400 KB Output is correct
30 Correct 3 ms 408 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 2 ms 400 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 3 ms 412 KB Output is correct
38 Correct 3 ms 340 KB Output is correct
39 Correct 3 ms 416 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 3 ms 468 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 3 ms 340 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 2 ms 468 KB Output is correct
50 Correct 2 ms 468 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 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 171 ms 9840 KB Output is correct
22 Correct 176 ms 10100 KB Output is correct
23 Correct 190 ms 10108 KB Output is correct
24 Correct 172 ms 10572 KB Output is correct
25 Correct 185 ms 9216 KB Output is correct
26 Correct 176 ms 11404 KB Output is correct
27 Correct 159 ms 13004 KB Output is correct
28 Correct 171 ms 9292 KB Output is correct
29 Correct 179 ms 9320 KB Output is correct
30 Correct 185 ms 9296 KB Output is correct
31 Correct 164 ms 10840 KB Output is correct
32 Correct 151 ms 13812 KB Output is correct
33 Correct 152 ms 11056 KB Output is correct
34 Correct 153 ms 14584 KB Output is correct
35 Correct 162 ms 14320 KB Output is correct
36 Correct 171 ms 10840 KB Output is correct
37 Correct 178 ms 10180 KB Output is correct
38 Correct 182 ms 10984 KB Output is correct
39 Correct 196 ms 10232 KB Output is correct
40 Correct 192 ms 10988 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 3 ms 524 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 3 ms 404 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 2 ms 324 KB Output is correct
48 Correct 2 ms 404 KB Output is correct
49 Correct 2 ms 400 KB Output is correct
50 Correct 3 ms 408 KB Output is correct
51 Correct 3 ms 340 KB Output is correct
52 Correct 2 ms 340 KB Output is correct
53 Correct 3 ms 340 KB Output is correct
54 Correct 2 ms 400 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 3 ms 412 KB Output is correct
58 Correct 3 ms 340 KB Output is correct
59 Correct 3 ms 416 KB Output is correct
60 Correct 2 ms 340 KB Output is correct
61 Correct 2 ms 468 KB Output is correct
62 Correct 2 ms 468 KB Output is correct
63 Correct 3 ms 468 KB Output is correct
64 Correct 2 ms 468 KB Output is correct
65 Correct 3 ms 340 KB Output is correct
66 Correct 3 ms 468 KB Output is correct
67 Correct 2 ms 468 KB Output is correct
68 Correct 2 ms 468 KB Output is correct
69 Correct 2 ms 468 KB Output is correct
70 Correct 2 ms 468 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 212 KB Output is correct
73 Correct 176 ms 10584 KB Output is correct
74 Correct 186 ms 10132 KB Output is correct
75 Correct 191 ms 9240 KB Output is correct
76 Correct 187 ms 9260 KB Output is correct
77 Correct 195 ms 9152 KB Output is correct
78 Correct 206 ms 10800 KB Output is correct
79 Correct 196 ms 11900 KB Output is correct
80 Correct 183 ms 10828 KB Output is correct
81 Correct 205 ms 11396 KB Output is correct
82 Correct 181 ms 10628 KB Output is correct
83 Correct 207 ms 11312 KB Output is correct
84 Correct 187 ms 12360 KB Output is correct
85 Correct 206 ms 11156 KB Output is correct
86 Correct 194 ms 11632 KB Output is correct
87 Correct 189 ms 12468 KB Output is correct
88 Correct 187 ms 13148 KB Output is correct
89 Correct 173 ms 13176 KB Output is correct
90 Correct 177 ms 14608 KB Output is correct
91 Correct 179 ms 13232 KB Output is correct
92 Correct 198 ms 13300 KB Output is correct
93 Correct 178 ms 14760 KB Output is correct
94 Correct 167 ms 13220 KB Output is correct
95 Correct 171 ms 13176 KB Output is correct
96 Correct 164 ms 14572 KB Output is correct
97 Correct 171 ms 13028 KB Output is correct
98 Correct 188 ms 10280 KB Output is correct
99 Correct 214 ms 10256 KB Output is correct
100 Correct 175 ms 10360 KB Output is correct
101 Correct 162 ms 14488 KB Output is correct
102 Correct 159 ms 13612 KB Output is correct