제출 #844422

#제출 시각아이디문제언어결과실행 시간메모리
844422vjudge1Pod starim krovovima (COCI20_psk)C++17
44 / 50
1 ms600 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define ll long long #define pri pair<int,int> #define prl pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define vp vector<pair<int,int>> #define vpl vector<pair<ll,ll>> #define re return 0 #define sqrt sqrtl int32_t main() { int n;cin>>n; ll sum = 0; vector<ll> st(n); for (int i = 0;i<n;i++) { ll t;cin>>t>>st[i]; sum+=t; } sort(st.begin(),st.end(),greater<int>()); vector<ll> c(n,0); ll a = 0; for (int i = 0;i<n;i++) { c[i] = min(st[i],sum); sum-=c[i]; if (c[i]==0) a++; } cout<<a<<endl; for (int i = 0;i<n;i++) { cout<<c[i]<<" "; }cout<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...