# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1264189 | vtnoo | Roller Coaster Railroad (IOI16_railroad) | C++20 | 26 ms | 3400 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN=16, INF=1e9;
pair<long long, int> dp[1<<MAXN];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t){
int n=s.size();
/* for(int i=0;i<n;i++)cout<<s[i]<<" ";
cout<<endl;
for(int i=0;i<n;i++)cout<<t[i]<<" ";
cout<<endl; */
dp[0]={0,1}; //metros, velocidad
for(int S=1;S<(1<<n);S++){
dp[S]={1e18, 1e9};
for(int i=n-1;i>=0;i--){
if(((1<<i)&S)){
int prevS=S^(1<<i);
long long need=0;
if(dp[prevS].second>s[i]){
need=dp[prevS].second-s[i];
}
/* cout<<"=================="<<endl;
cout<<t[i]<<endl; */
dp[S]=min(dp[S],{dp[prevS].first+need,t[i]});
/* cout<<need<<endl;
cout<<S<<endl;
cout<<dp[S].first<<" "<<dp[S].second<<endl; */
}
}
}
//cout<<dp[(1<<n)-1].second<<endl;
return dp[(1<<n)-1].first;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |