# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017185 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 432 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>
using namespace std;
#define int long long
int const N=2e5+5;
int const mod=1e9+7;
signed main(){
int n;
cin>>n;
vector<pair<int,int>> gla;
int li=0;
for (int i = 0; i < n; ++i)
{
int a;
cin>>a;
li+=a;
cin>>a;
gla.push_back({a,i});
}
sort(gla.begin(), gla.end());
reverse(gla.begin(), gla.end());
int ans[n]={0};
int c=0;
for(auto [v,i]:gla){
ans[i]=min(v,li);
if(ans[i]==0)
c++;
li-=min(v,li);
}
cout<<c<<endl;
for (int i = 0; i < n; ++i)
cout<<ans[i]<<' ';
cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |