제출 #420515

#제출 시각아이디문제언어결과실행 시간메모리
420515PetiRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
160 ms8092 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); vector<int> compr; compr.reserve(2*n); for(int x : s) compr.push_back(x); for(int x : t) compr.push_back(x); sort(compr.begin(), compr.end()); compr.erase(unique(compr.begin(), compr.end()), compr.end()); vector<int> va(n), vb(n); for(int i = 0; i < n; i++){ va[i] = lower_bound(compr.begin(), compr.end(), s[i])-compr.begin(); vb[i] = lower_bound(compr.begin(), compr.end(), t[i])-compr.begin(); } int m = (int)compr.size(); vector<int> fok(m); for(int i = 0; i < n; i++){ fok[va[i]]++; fok[vb[i]]--; } fok[0]--; fok[m-1]++; for(int i = 0; i < m-1; i++){ if(fok[i] <= 0) fok[i+1] += fok[i]; else return 0; } if(fok[m-1] == 0) return 1; 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...