# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249696 | dvdg6566 | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=300001;
const ll MAXK=1000001;
const ll INF = 1e9;
const ll MOD = 1e9+7;
ll out[MAXN];
vpi V;
ll N,X,a,b;
int main(){
cin>>N;
for(int i=1;i<=N;++i){
cin>>a>>b;
X+=a;
V.pb(b,i);
}
sort(ALL(V));
while(X){
pi t=V.back();V.pop_back();
out[t.s]=min(t.f,X);
X-=out[t.s];
}
for(int i=1;i<=N;++i)cout<<out[i]<<' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |