# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339953 | Hazem | Pod starim krovovima (COCI20_psk) | C++14 | 3 ms | 384 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.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 2e5 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
vector<pair<pair<int,int>,int>>vec;
int ans[N];
int main()
{
//freopen("out.txt","w",stdout);
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
int a,b;
scanf("%d%d",&a,&b);
vec.push_back({{b,a},i});
}
sort(vec.begin(),vec.end());
for(int i=0;i<vec.size();i++)
for(int j=vec.size()-1;j>i;j--){
int mn = min(vec[i].F.S,vec[j].F.F-vec[j].F.S);
vec[i].F.S -= mn,vec[j].F.S += mn;
}
int cnt = 0;
for(auto x:vec)
ans[x.S] = x.F.S,cnt += !ans[x.S];
printf("%d\n",cnt);
for(int i=1;i<=n;i++)
printf("%d ",ans[i]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |