Submission #1136312

#TimeUsernameProblemLanguageResultExecution timeMemory
1136312alterioRoller Coaster Railroad (IOI16_railroad)C++20
34 / 100
59 ms13380 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int mxn = 16; int n; vector<int> s, t; ll dp[mxn][1 << mxn]; ll solve(int last, int mask) { if (mask == (1 << n) - 1) return 0; if (dp[last][mask] != -1) return dp[last][mask]; ll ans = 1e15; for (int i = 0; i < n; i++) { if ((1 << i) & mask) continue; ans = min(ans, max(0, t[last] - s[i]) + solve(i, mask | (1 << i))); } return dp[last][mask] = ans; } ll plan_roller_coaster(vector<int> _s, vector<int> _t) { s = _s; t = _t; n = s.size(); memset(dp, -1, sizeof(dp)); ll ans = 1e15; for (int i = 0; i < n; i++) ans = min(ans, solve(i, (1 << i))); return ans; }

Compilation message (stderr)

railroad.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
railroad_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...