# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
84458 | farukkastamonuda | Schools (IZhO13_school) | C++14 | 2077 ms | 17788 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 300005
#define ii pair<lo int, pair<int, pair<int, pair<int,int> > > >
using namespace std;
int n,m,s;
lo int x[li],y[li],total;
priority_queue<ii> q;
int main(){
scanf("%d %d %d",&n,&m,&s);
for(int i=1;i<=n;i++){
scanf("%lld %lld",&x[i],&y[i]);
}
q.push(mp(0,mp(m+s,mp(m,mp(s,0)))));
while(!q.empty()){
ii tmp=q.top();
q.pop();
lo int cst=tmp.fi;
int mm=tmp.se.se.fi;
int ss=tmp.se.se.se.fi;
int ind=tmp.se.se.se.se;
if(ind==n){
total=max(total,cst);
continue;
}
if(mm>0) q.push(mp(cst+x[ind+1],mp(tmp.se.fi-1,mp(mm-1,mp(ss,ind+1)))));
if(ss>0) q.push(mp(cst+y[ind+1],mp(tmp.se.fi-1,mp(mm,mp(ss-1,ind+1)))));
q.push(mp(cst,mp(tmp.se.fi,mp(mm,mp(ss,ind+1)))));
}
printf("%lld\n",total);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |