# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
638245 | colazcy | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cassert>
#include <algorithm>
#define let const auto
#define rep(name,beg,end) for(auto lim_##name = end,name = beg;name <= lim_##name;name++)
#define per(name,beg,end) for(auto lim_##name = end,name = beg;name >= lim_##name;name--)
#define repn(lim) for(auto REPN_lIM = lim,REPN = 1;REPN <= REPN_lIM;REPN++)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define trace() debug("line : %d, Function : %s\n",__LINE__,__FUNCTION__)
using ll = long long;
constexpr int maxn = 1e5 + 100;
struct Node{
int id,now,cap;
}val[maxn];
ll sum;
int n,ans[maxn];
int main(){
#ifndef ONLINE_JUDGE
// std::freopen("fufu.in","r",stdin);
#endif
std::scanf("%d",&n);
rep(i,1,n){
val[i].id = i;
std::scanf("%d %d",&val[i].now,&val[i].cap);
sum += val[i].now;
}
std::sort(val + 1,val + 1 + n,[](const Node a,const Node b){return a.cap > b.cap;});
int cnt = n;
rep(i,1,n){
ans[val[i].id] = std::min(sum,(ll)val[i].cap);
sum -= val[i].cap;
cnt--;
if(sum <= 0)break;
}
std::printf("%d\n",cnt);
rep(i,1,n)std::printf("%d ",ans[i]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |