제출 #590758

#제출 시각아이디문제언어결과실행 시간메모리
590758VanillaRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
426 ms25448 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); multiset <pair <int, int> > ms; map <pair <int, int>, int> mp; pair <int, int> bad = {-1, -1}; for (int i = 0; i < n; i++) { ms.insert({s[i], t[i]}); mp[{s[i], t[i]}]++; } for (int i = 0; i < n; i++){ auto it = ms.lower_bound({t[i], -1}); if (it == ms.end()){ bad = {s[i], t[i]}; } else { if (*it == make_pair(s[i], t[i]) && mp[{s[i], t[i]}] == 1) it++; if (it == ms.end()) { bad = {s[i], t[i]}; } } } int last = 1; for (int i = 0; i < n; i++){ auto it = ms.lower_bound({last, 0}); // cout << i << " " << last << " " << it->first << " " << it->second << "\n"; if (it != ms.end() && *it == bad && i != n-1) it++; if (it == ms.end()) return 1; last = it->second; ms.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...