# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
844639 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int N;cin>>N;
ll m=0;
vector<pair<ll,int>> Z;
for(int i=0;i<N;i++){
ll t,x;cin>>t>>x;
m+=t;
Z.push_back(make_pair(x,i));
}
sort(Z.begin(),Z.end(),greater<pair<ll,int>>());
ll p=0;
vector<ll> ZR(N);
for(int i=0;i<N;i++){
ZR[Z[i].second] = min(m,Z[i].first);
m-=ZR[Z[i].second];
if(ZR[Z[i].second]==0){p++;}
}
cout<<p<<endl;
for(auto &i:ZR)cout<<i<<" ";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |