# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844228 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 600 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.
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define int long long int
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 5e5 + 5;
inline void solve(){
int n;
cin >> n;
int a[n];
pair<int, int> b[n];
rep(i, 0, n) cin >> a[i] >> b[i].ff;
rep(i, 0, n) b[i].ss = i;
sort(b, b+n);
int sum = acc(a, a+n, 0LL);
rev(b, b+n);
int ans[n];
int in = 0;
while(sum > 0){
ans[b[in].ss] = min(b[in].ff, sum);
sum = max(0LL, sum - b[in].ff);
in++;
}
while(in < n) ans[b[in].ss] = 0, in++;
int cnt = 0;
rep(i, 0, n) if(ans[i] == 0) cnt++;
cout << cnt << endl;
rep(i, 0, n) cout << ans[i] << " ";
cout << endl;
}
int32_t main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |