제출 #276541

#제출 시각아이디문제언어결과실행 시간메모리
276541arayiRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
80 ms9208 KiB
#include "railroad.h" #include <bits/stdc++.h> #define lli long long int using namespace std; const int N = 1e5 + 30; int n, i1; lli dp[20][N], mn = 1e11; long long plan_roller_coaster(vector<int> s, vector<int> t) { n = s.size(); for (int i = 0; i < n; i++) { if(s[i] < mn) mn = s[i], i1 = i; } for (int x = 0; x < (1 << n); x++) { for (int i = 0; i < n; i++) { if((1 << i) & x) { if(x - (1 << i) == 0) continue; dp[i][x] = 1e11; for (int j = 0; j < n; j++) { if(i == j) continue; if((1 << j) & x) dp[i][x] = min(max(0, t[i] - s[j]) + dp[j][x - (1 << i)], dp[i][x]); } } } } return dp[i1][(1 << n) - 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...