# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092746 | Hacv16 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 360 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 int
const int MAX = 2e5 + 10;
int n, t[MAX], z[MAX];
int ans[MAX];
int32_t main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> t[i] >> z[i];
vector<int> glasses(n);
iota(glasses.begin(), glasses.end(), 1);
sort(glasses.begin(), glasses.end(), [&](int i, int j){
return z[i] > z[j];
});
int totalDrink = accumulate(t + 1, t + 1 + n, 0LL);
int respZero = 0;
for(auto glassId : glasses)
{
ans[glassId] = min(z[glassId], totalDrink);
totalDrink -= min(z[glassId], totalDrink);
if(!ans[glassId]) respZero++;
}
cout << respZero << '\n';
for(int i = 1; i <= n; i++)
cout << ans[i] << ' ';
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |