Submission #103017

#TimeUsernameProblemLanguageResultExecution timeMemory
103017Osama_AlkhodairyRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
119 ms7788 KiB
// name = railroad_gk_wa.cpp, type = cpp.g++11 #include "railroad.h" #include <bits/stdc++.h> using namespace std; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); vector < pair <int, int> > e; for (int i = 0; i < n; i++) { e.push_back(make_pair(s[i], 1)); e.push_back(make_pair(t[i], -1)); } sort(e.begin(), e.end()); int sz = e.size(); int balance = 0; bool source = false; int beg = 0; while (beg < sz) { int end = beg; while (end + 1 < sz && e[end + 1].first == e[end].first) { end++; } for (int j = beg; j <= end; j++) { balance += e[j].second; } if (balance > 1) { return 1; } if (balance == 1) { if (source) { return 1; } balance--; source = true; } beg = end + 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...