# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339953 | 2020-12-26T12:11:45 Z | Hazem | Pod starim krovovima (COCI20_psk) | C++14 | 3 ms | 384 KB |
/* 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 364 KB | Output is correct |
9 | Correct | 2 ms | 364 KB | Output is correct |
10 | Correct | 3 ms | 364 KB | Output is correct |