Submission #844633

# Submission time Handle Problem Language Result Execution time Memory
844633 2023-09-05T15:09:58 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
40 / 50
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
int N;cin>>N;
vector<ll> T(N);
vector<pair<ll,int>> Z;
for(int i=0;i<N;i++){
    cin>>T[i];
    ll x;cin>>x;Z.push_back(make_pair(x,i));
}
ll m = accumulate(T.begin(),T.end(),0);
sort(Z.begin(),Z.end(),greater<pair<ll,int>>());
bool flag = true;
for(int i=0;i<N;i++){
	ll dec = min(get<0>(Z[i]),m);
	Z[i] = make_pair(dec,get<1>(Z[i]));
	m-=dec;
	if(m==0 && flag){cout<<N-i-1<<endl;flag=false;}
}
vector<ll> ZR(N);
for(int i=0;i<N;i++){
    ZR[get<1>(Z[i])]=get<0>(Z[i]);
}
for(auto &i:ZR)cout<<i<<" ";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct