Submission #413529

#TimeUsernameProblemLanguageResultExecution timeMemory
413529Mamnoon_SiamRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
134 ms9648 KiB
#ifndef LOCAL #include "railroad.h" #endif #include <bits/stdc++.h> using namespace std; using ii = pair<int, int>; using ll = long long; using vi = vector<int>; #define all(v) begin(v), end(v) #define sz(v) (int)(v.size()) #define fi first #define se second ll plan_roller_coaster(vi s, vi t) { int n = sz(s); vi ps(n); iota(all(ps), 0); sort(all(ps), [&s](int i, int j){ return s[i] < s[j]; }); vi swhere(n); for(int i = 0; i < n; ++i) { swhere[ps[i]] = i; } vi pt(n); iota(all(pt), 0); sort(all(pt), [&t,&swhere](int i, int j){ return t[i] == t[j] ? swhere[i] > swhere[j] : t[i] < t[j]; }); sort(all(s)); sort(all(t)); int ptr = sz(s); for(int i = sz(t)-1; i >= 0; --i) { while(ptr and s[ptr-1] >= t[i]) { --ptr; } int S = n - i; int NS = n - ptr - swhere[pt[i]]; if(S - NS > 1) return 1; } return 0; } #ifdef LOCAL int main() { freopen("01", "r", stdin); int n; assert(1 == scanf("%d", &n)); std::vector<int> s(n), t(n); for (int i = 0; i < n; ++i) assert(2 == scanf("%d%d", &s[i], &t[i])); long long ans = plan_roller_coaster(s, t); printf("%lld\n", ans); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...