제출 #403297

#제출 시각아이디문제언어결과실행 시간메모리
403297ja_kingyRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
103 ms11444 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; ll INF = 2e9; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); vector<pii> order; for (int i = 0; i < n; ++i) { order.push_back({t[i], -1}); order.push_back({s[i], 1}); } order.push_back({INF, 1}); order.push_back({1, -1}); sort(order.begin(), order.end()); reverse(order.begin(), order.end()); ll d = 0, ans = 0; for (pii p: order) { if (p.second == 1) { if (d < 0) ans -= p.first; d++; } if (p.second == -1) { if (d <= 0) ans += p.first; d--; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...