# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440460 | mashrur_hossain | 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>
#define fast_cin ios_base::sync_with_stdio(0); cin.tie(NULL); cerr.tie(NULL);
#define endl "\n"
#define dbg(x) cerr << #x << ": " << x << endl;
#define DBG cerr << __LINE__ << ": I GOT STUCK\n";
using namespace std;
typedef long long ll;
typedef long double db;
void solve(){
ll n;cin >> n;
ll tot = 0;
vector<pair<ll, ll>>v;
for(ll i = 0;i<n;i++){
ll t,z;cin >> t >> z;
tot += t;
v.emplace_back(z, i);
}
sort(v.rbegin(), v.rend());
vector<ll>ans(n, 0);
for(ll i = 0;i<n;i++){
if(tot > v[i].first){
// fill it up
ans[v[i].second] = v[i].first;
tot -= v[i].first;
}
else{
// the rest are empty
ans[v[i].second] = tot;
break;
}
}
ll cnt = 0;
for(ll i = 0;i<n;i++){
if(ans[i] == 0)cnt++;
}
cout << cnt << endl;
for(ll i = 0;i<n;i++){
cout << ans[i] << " \n"[i==n-1];
}
}
int main() {
fast_cin;
int test;test = 1;
// int test;cin >>test;
while(test--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |