# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017181 | 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 <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y,su=0;
vector<pair<int,int>> cap;
for (int i=0;i<n;i++)
{
cin>>x>>y;
su+=x;
cap.push_back({y,i});
}
sort(rbegin(cap),rend(cap));
int ans=0,a[n]={};
if (!su)
ans=n;
else
{
for (int i=0;i<n;i++)
{
a[cap[i].second]=min(cap[i].first,su);
su-=a[cap[i].second];
if (!su)
{
ans=n-i-1;
break;
}
}
}
cout<<ans<<endl;
for (int i=0;i<n;i++)
cout<<a[i]<<' ';
cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |