# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
440460 | mashrur_hossain | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fast_cin ios_base::sync_with_stdio(0); cin.tie(NULL); cerr.tie(NULL);
#define endl "\n"
#define dbg(x) cerr << #x << ": " << x << endl;
#define DBG cerr << __LINE__ << ": I GOT STUCK\n";
using namespace std;
typedef long long ll;
typedef long double db;
void solve(){
ll n;cin >> n;
ll tot = 0;
vector<pair<ll, ll>>v;
for(ll i = 0;i<n;i++){
ll t,z;cin >> t >> z;
tot += t;
v.emplace_back(z, i);
}
sort(v.rbegin(), v.rend());
vector<ll>ans(n, 0);
for(ll i = 0;i<n;i++){
if(tot > v[i].first){
// fill it up
ans[v[i].second] = v[i].first;
tot -= v[i].first;
}
else{
// the rest are empty
ans[v[i].second] = tot;
break;
}
}
ll cnt = 0;
for(ll i = 0;i<n;i++){
if(ans[i] == 0)cnt++;
}
cout << cnt << endl;
for(ll i = 0;i<n;i++){
cout << ans[i] << " \n"[i==n-1];
}
}
int main() {
fast_cin;
int test;test = 1;
// int test;cin >>test;
while(test--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |