Submission #844639

# Submission time Handle Problem Language Result Execution time Memory
844639 2023-09-05T15:15:15 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
50 / 50
1 ms 348 KB
#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
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct