제출 #421583

#제출 시각아이디문제언어결과실행 시간메모리
421583balbitRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
72 ms15920 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair <int, int > #define f first #define s second #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #define MX(a,b) a = max(a,b) #define MN(a,b) a = min(a,b) #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__) template<typename T> void _do(T && x) {cerr<<x<<endl;} template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);} #else #define bug(...) #endif // BALBIT #define pb push_back #define REP(i,n) for (int i = 0; i<(n); ++i) #define REP1(i,n) for (int i = 1; i<=(n); ++i) //signed main(){ // bug(1,2); //} ll dp[1<<16][17]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); memset(dp, 0x3f, sizeof dp); ll re = 0x3f3f3f3f3f3f3f3f; REP(m,1<<n) { REP(v,n) { if (m & (1<<v)) { if (m==(1<<v)) { dp[m][v] = 0; continue; } REP(u,n) { if (u!=v && m & (1<<u)) { MN(dp[m][v], dp[m^(1<<v)][u] + max(0, t[u] - s[v])); } } } if (m == (1<<n)-1) { MN(re, dp[m][v]); } } } return re; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...