# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
638248 | 2022-09-05T06:13:17 Z | Register | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 212 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1005; int n,cnt,id[N],a[N],b[N],ans[N]; ll s; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),s+=a[i],id[i]=i; sort(id+1,id+n+1,[&](int x,int y){return b[x]>b[y];}); cnt=n; for(int i=1;i<=n&&s;i++) cnt--,s-=(ans[id[i]]=min(s,(ll)b[id[i]])); printf("%d\n",cnt); for(int i=1;i<=n;i++) printf("%d ",ans[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |