제출 #420503

#제출 시각아이디문제언어결과실행 시간메모리
420503PetiRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
172 ms20152 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]); vb[i] = *lower_bound(compr.begin(), compr.end(), t[i]); } 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++) fok[i+1] += fok[i]; 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...