이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int N = (int) s.size();
vector<vector<long long> > bestDP ((1 << N) + 1, vector<long long> (N, ((long long) 1 << 62)));
for (int i = 0; i < N; i++){
bestDP[(1 << i)][i] = 0;
//cout << s[i] << ' ' << t[i] << endl;
}
for (long long rails = 1; rails < (1 << N); rails++){
for (long long last = 0; last < N; last++){
if (rails & (1 << last)){
for (int second_last = 0; second_last < N; second_last++){
bestDP[rails][last] = min(bestDP[rails][last], bestDP[rails ^ (1 << last)][second_last] + max(0, t[second_last] - s[last]));
//cout << ' ' << rails << ' ' << last << ' ' << second_last << ' ' << bestDP[rails ^ (1 << last)][second_last] << ' ' << t[second_last] << ' ' << s[last] << endl;
}
}
//cout << bestDP[rails][last] << ' ' << rails << ' ' << last << endl;
}
}
long long best = ((long long) 1 << 62);
for (int i = 0; i < N; i++){
best = min(best, bestDP[(1 << N) - 1][i]);
//cout << bestDP[(1 << N) - 1][i] << endl;
}
return best;
}
# | 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... |