Submission #587950

#TimeUsernameProblemLanguageResultExecution timeMemory
587950AriaHRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
144 ms10684 KiB
#include "railroad.h" /* Ignore Others Only Focus On Yourself! */ /* Im the Best! */ #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair < int, int > pii; typedef pair < ll, ll > pll; #define F first #define S second #define all(x) x.begin(),x.end() #define Mp make_pair #define point complex #define endl '\n' #define SZ(x) (int)x.size() #define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define file_io freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout); #define mashtali return cout << "Hello, World!", 0; const int N = 1e6 + 10; const int LOG = 20; const ll mod = 1e9 + 7; const ll inf = 8e18; const double pi = acos(-1); const ld eps = 1e-18; const ld one = 1.; ll pw(ll a, ll b, ll M, ll ret = 1) { if(a == 0) return 0; a %= M; while(b) { ret = (b & 1? ret * a % M : ret), a = a * a % M, b >>= 1; } return ret % M; } mt19937 rng(time(nullptr)); vector < int > cm; int ps[N]; int lwr(int x) { return lower_bound(all(cm), x) - cm.begin(); } ll plan_roller_coaster(vector < int > s, vector < int > t) { int n = SZ(s); for(int i = 0; i < n; i ++) { cm.push_back(s[i]); cm.push_back(t[i]); } cm.push_back(-1e9 - 5); cm.push_back(1e9 + 5); sort(all(cm)); cm.resize(unique(all(cm)) - cm.begin()); for(int i = 0; i < n; i ++) { ///printf("here i = %d s = %d t = %d\n", i, s[i], t[i]); s[i] = lwr(s[i]); t[i] = lwr(t[i]); if(s[i] <= t[i]) { ps[s[i]] --; ps[t[i]] ++; } else { ps[t[i]] ++; ps[s[i]] --; } ///printf("i = %d s = %d t = %d\n", i, s[i], t[i]); } ll tot = 0; for(int i = 1; i <= SZ(cm); i ++) { ///printf("i = %d ps = %d\n", i, ps[i]); ps[i] += ps[i - 1]; } for(int i = 0; i < SZ(cm) - 1; i ++) { if(ps[i] >= -1) continue; tot += 1ll * (-1 - ps[i]) * (cm[i + 1] - cm[i]); } return tot; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...