# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
886523 | 2023-12-12T09:24:38 Z | Kel_Mahmut | Gym Badges (NOI22_gymbadges) | C++14 | 351 ms | 27452 KB |
#include <bits/stdc++.h> #define pb push_back #define all(aa) aa.begin(), aa.end() using namespace std; typedef long long ll; int main(){ int n; cin >> n; vector<ll> L(n), X(n); for(int i = 0; i < n; i++) cin >> X[i]; for(int i = 0; i < n; i++) cin >> L[i]; vector<pair<ll, ll>> G(n); for(int i = 0; i < n; i++){ G[i] = make_pair(L[i], X[i]); } sort(all(G)); priority_queue<ll> vals; ll score = 0, ans = 0; for(int i = 0; i < n; i++){ auto [Li, Xi] = G[i]; if(score <= Li){ vals.push(Xi); score += Xi; ans++; } else if(vals.top() > Xi){ score -= vals.top(); vals.pop(); score += Xi; vals.push(Xi); } } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
8 | Incorrect | 0 ms | 348 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 312 ms | 15908 KB | Output is correct |
2 | Correct | 349 ms | 23620 KB | Output is correct |
3 | Correct | 351 ms | 23764 KB | Output is correct |
4 | Correct | 324 ms | 23724 KB | Output is correct |
5 | Correct | 332 ms | 23776 KB | Output is correct |
6 | Correct | 297 ms | 23428 KB | Output is correct |
7 | Correct | 312 ms | 22484 KB | Output is correct |
8 | Correct | 286 ms | 23172 KB | Output is correct |
9 | Correct | 294 ms | 23364 KB | Output is correct |
10 | Correct | 286 ms | 23380 KB | Output is correct |
11 | Correct | 268 ms | 24064 KB | Output is correct |
12 | Correct | 263 ms | 27452 KB | Output is correct |
13 | Correct | 259 ms | 24004 KB | Output is correct |
14 | Correct | 265 ms | 27304 KB | Output is correct |
15 | Correct | 260 ms | 26412 KB | Output is correct |
16 | Correct | 276 ms | 23500 KB | Output is correct |
17 | Correct | 285 ms | 23620 KB | Output is correct |
18 | Correct | 279 ms | 23600 KB | Output is correct |
19 | Correct | 283 ms | 23128 KB | Output is correct |
20 | Correct | 275 ms | 22936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
8 | Incorrect | 0 ms | 348 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
8 | Incorrect | 0 ms | 348 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |