# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
308043 | ErdosSzekeres | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long
#define pii pair<int,int>
#define pll pair<ll, ll>
const int MAXN = 1e3+7;
pll v[MAXN];
ll ans[MAXN];
ll total = 0;
int main(){
fastio;
int n; cin>>n;
for(int i=0; i<n; i++){
ll ti,zi;
cin>>ti>>zi;
total += ti;
v[i] = {zi, i};
}
sort(v, v+n);
int cnt = 0;
for(int i=n-1; i>=0; i--){
ans[v[i].second] = min(v[i].first, total);
total = max(0LL, total - v[i].first);
if(ans[v[i].second]==0)cnt++;
}
cout<<cnt<<endl;
for(int i=0; i<n; i++){
if(i>0)cout<<" ";
cout<<ans[i];
}
cout<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |