# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
732231 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 368 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 int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main(){
fast;
int n;
cin>>n;
int a[n],b[n],s=0;
vector<pair<int,int>>v;
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
s+=a[i];
v.pb({b[i],i});
}
sort(all(v));
int ans[n],cnt=0;
for(int i=v.size()-1;i>=0;i--){
if(s==0)cnt++;
ans[v[i].ss]=min(s,v[i].ff);
s-=min(s,v[i].ff);
}
cout<<cnt<<endl;
for(int i=0;i<n;i++)cout<<ans[i]<<" ";
cout<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |