| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1287124 | red_souls | Gym Badges (NOI22_gymbadges) | C++20 | 145 ms | 10432 KiB |
#include <bits/stdc++.h>
#define ll long long
#define task "gymbadges"
using namespace std;
const int N = 5e5 + 16;
int n;
pair <ll, ll> a[N];
namespace sub4 {
bool cmp(pair <ll, ll> a, pair <ll, ll> b) {
return a.first + a.second < b.first + b.second;
}
priority_queue <int> pq;
int result;
void solve() {
sort(a + 1, a + 1 + n, cmp);
ll sum = 0;
for (int i = 1; i <= n; i++) {
if (sum <= a[i].second) {
sum += a[i].first;
result++;
pq.push(a[i].first);
}
else {
sum += a[i].first;
pq.push(a[i].first);
sum -= pq.top();
pq.pop();
}
}
cout << result;
}
}
int main() {
ios_base :: sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].first;
}
for (int i = 1; i <= n; i++) {
cin >> a[i].second;
}
sub4 :: solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
