# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844533 | 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 <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pri pair<int,int>
#define prl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define re return 0
#define sqrt sqrtl
int32_t main() {
int n;cin>>n;
ll sum = 0;
vector<prl> st(n);
for (int i = 0;i<n;i++) {
ll t,x;cin>>t>>x;
st[i] = {x,i};
sum+=t;
}
sort(st.begin(),st.end(),greater<prl>());
vector<ll> c(n,0);
ll a = 0;
for (int i = 0;i<n;i++) {
c[st[i].second] = min(st[i].first,sum);
sum-=c[st[i].second];
if (c[st[i].second]==0) a++;
}
cout<<a<<endl;
for (int i = 0;i<n;i++) {
cout<<c[i]<<" ";
}cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |