# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863399 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long
using namespace std;
typedef tuple<int, int, int> iii;
typedef long long ll;
const int mod =998244353;
int n, sum;
int t[1005], ans[1005];
pair<int, int> v[1005];
int32_t main(){
fast;
cin>>n;
for(int i=1;i<=n;i++){
cin>>t[i]>>v[i].fi;
v[i].se=i;
sum+=t[i];
}
sort(v+1, v+n+1, greater<pair<int, int>>());
for(int i=1;i<=n;i++){
if(sum<=0){
cout<<n-i+1<<endl;
break;
}
ans[v[i].se]=min(v[i].fi, sum);
sum-=v[i].fi;
}
for(int i=1;i<=n;i++){
cout<<ans[i]<<" ";
}
cout<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |