# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1099596 | Petrix | 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 <algorithm>
using namespace std;
#define int long long
int rasp[1001];
struct pahar{
int a,ind;
} v[1001];
bool cmp(pahar a,pahar b){
return a.a>b.a;
}
signed main()
{
int i,a,n,sum=0,cnt=0;
cin>>n;
for(i=1;i<=n;i++){
cin>>a>>v[i].a;
v[i].ind=i;sum+=a;
}
sort(v+1,v+n+1,cmp);
for(i=1;i<=n;i++){
if(sum){
rasp[v[i].ind]=min(sum,v[i].a);
sum-=min(sum,v[i].a);
}else cnt++;
}
cout<<cnt<<"\n";
for(i=1;i<=n;i++) cout<<rasp[i]<<" ";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |