Submission #397316

#TimeUsernameProblemLanguageResultExecution timeMemory
397316peuchRoller Coaster Railroad (IOI16_railroad)C++17
11 / 100
2071 ms22084 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; int n; vector<int> ord; vector<int> S, T; long long ans = 1e18; void bt(int i, long long sum); long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { S = s; T = t; n = s.size(); ord = vector<int> (n); for(int i = 0; i < n; i++) ord[i] = i; bt(0, 0); return ans; } void bt(int i, long long sum){ if(sum > ans) return; if(i == n){ ans = sum; return; } for(int j = i; j < n; j++){ swap(ord[i], ord[j]); if(i != 0) sum += max(T[ord[i - 1]] - S[ord[i]], 0); bt(i + 1, sum); if(i != 0) sum -= max(T[ord[i - 1]] - S[ord[i]], 0); swap(ord[i], ord[j]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...