# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440532 | Abrar_Al_Samit | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 332 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 std;
using namespace __gnu_pbds;
#define debug(x) cerr << '[' << (#x) << "] = " << x << '\n';
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update> ;
void PlayGround() {
int n; cin >> n;
long long sum = 0;
vector<pair<long long, long long>>vol(n);
for(int i=0; i<n; ++i) {
int x; cin >> x;
sum += x;
cin >> vol[i].first;
vol[i].second = i;
}
sort(vol.rbegin(), vol.rend());
vector<long long>config(n);
long long ans = 0;
for(int i=0; i<n; ++i) {
int cur = min(sum, vol[i].first);
if(cur==0) ++ans;
sum -= cur;
config[vol[i].second] = cur;
}
cout << ans << '\n';
for(auto it : config) cout << it << ' ';
cout << '\n';
#ifndef ONLINE_JUDGE
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// #endif
PlayGround();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |