# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868760 | Pring | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fs first
#define sc second
#define mp make_pair
typedef pair<int, int> pii;
typedef pair<pii, int> p3i;
const int MXN = 1005;
int n, sum;
p3i p[MXN];
void miku() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p[i].fs.sc >> p[i].fs.fs;
sum += p[i].fs.sc;
p[i].fs.sc = 0;
p[i].sc = i;
}
sort(p, p + n, greater<p3i>());
for (int i = 0; i < n; i++) {
if (sum >= p[i].fs.fs) {
p[i].fs.sc = p[i].fs.fs;
sum -= p[i].fs.fs;
} else {
p[i].fs.sc = sum;
break;
}
}
sort(p, p + n, [](p3i a, p3i b) -> bool {
return a.sc < b.sc;
});
int ans = 0;
for (int i = 0; i < n; i++) if (p[i].fs.sc == 0) ans++;
cout << ans << endl;
for (int i = 0; i < n; i++) cout << p[i].fs.sc << ' ';
cout << endl;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
miku();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |