제출 #100019

#제출 시각아이디문제언어결과실행 시간메모리
100019shenxyRoller Coaster Railroad (IOI16_railroad)C++11
11 / 100
493 ms25528 KiB
#include "railroad.h" #include <algorithm> #include <vector> #include <map> #include <utility> #define INF 1E18 using namespace std; int N; long long int plan_roller_coaster(vector<int> s, vector<int> t) { N = s.size(); if (N <= 8) { vector<int> u; for (int i = 0; i < 8; i++) { u.push_back(i); } long long int ans = 0; for (int i = 1; i < 8; i++) { ans += max(0, t[u[i - 1]] - s[u[i]]); } while (next_permutation(u.begin(), u.end())) { long long int temp = 0; for (int i = 1; i < 8; i++) { temp += max(0, t[u[i - 1]] - s[u[i]]); } ans = min(ans, temp); } return ans; } multimap<int, int> mymap; for (int i = 0; i < N; i++) { mymap.insert({s[i], t[i]}); } int nowspeed = mymap.begin() -> second; mymap.erase(mymap.begin()); while (!mymap.empty()) { multimap<int, int>::iterator it = mymap.lower_bound(nowspeed); if (it == mymap.end()) return 1; nowspeed = it -> second; if (mymap.lower_bound(nowspeed) == mymap.end()) { it++; nowspeed = it -> second; } mymap.erase(it); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...