# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844874 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int int64_t
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
#define F first
#define S second
#define I insert
#define PB push_back
#define POB pop_back
#define sqr(a) ((a) * (a))
#define P pop
#define max3(a, b, c) (max(a, max(b, c)))
#define max4(a, b, c, d) (max(max(a, b), max(c, d)))
#define min3(a, b, c) (min(a, min(b, c)))
#define min4(a, b, c, d) (min(min(a, b), min(c, d)))
#define MOD 1000000007
#define mod 998244353
int binpow(int a, int p, int m = MOD) {
int ans = 1;
while (p) {
if (p & 1) ans = ((ans % m) * (a % m)) % m;
a = sqr(a) % m;
p >>= 1;
}
return ans;
}
void solve() {
int n;
cin >> n;
vector<pair<int, int>> z(n, {0, 0});
int liqu = 0;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp >> z[i].F;
liqu += tmp;
z[i].S = i;
}
sort(z.rbegin(), z.rend());
vector<pair<int, int>> ans(n, {0, 0});
int ansi = 0;
for (int i = 0; i < n; i++) {
ans[i].F = z[i].S;
ans[i].S = min(z[i].F, liqu);
liqu -= ans[i].S;
if (ans[i].S == 0) ansi++;
}
sort(ans.begin(), ans.end());
cout << ansi << endl;
for (int i = 0; i < n; i++) {
cout << ans[i].S;
if (i != n - 1) cout << ' ';
}
}
int32_t main() {
int t = 1;
while (t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |