# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
844282 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++11 | 1 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lg(a) (31 - __builtin_clz((a)))
#define endl ("\n")
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define all(aa) aa.begin(), aa.end()
#define rall(aa) aa.rbegin(), aa.rend()
#define forn(i, n) for(int i=0;i<n;i++)
#define trav(e, x) for(auto& e:x)
#define until(n, v) (int) (lower_bound(v.begin(), v.end(), n)-v.begin()) //# of elements < n
#define after(n, v) (int) (v.end()-upper_bound(v.begin(), v.end(), n)) //# of elements > n
#define sameas(n, v) (int) (upper_bound(v.begin(), v.end(), n) - lower_bound(v.begin(), v.end(), n)) //# of elements ==n
typedef long long ll;
using namespace std;
/*
*/
void solve(){
int n; cin>>n;
vector<pair<ll, ll>> V(n);
vector<ll> L(n);
for(int i=0;i<n;i++){
ll l, v;
cin >> l >> v;
L[i] = l, V[i] = mp(v, i);
}
for(auto &e:L) cin>>e;
ll liq = accumulate(all(L), 0);
sort(rall(V));
vector<ll> ans(n, 0);
int empty=n;
for(int i=0; liq>0;i++){
ans[V[i].second] = min(liq, V[i].first); empty--;
liq-=min(liq, V[i].first);
}
cout<<empty<<endl;
for(auto e: ans) cout<<e<<' ';
}
int main(){
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |