제출 #539718

#제출 시각아이디문제언어결과실행 시간메모리
539718Eug1enaRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
158 ms9796 KiB
#include <bits/stdc++.h> using namespace std; using lint = long long; #define rep(i, n) for(int i = 0; i < int(n); i++) #define rep2(i, l, n) for(int i = int(l); i < int(n); i++) #define repr(i, n) for(int i = int(n) - 1; i >= 0; i--) #define all(x) (x).begin(), (x).end() inline int has(lint x, int k){ return (x >> k) & 1; }; struct UnionFind{ int sz; vector<int> par; UnionFind(int n){ sz = n; par.resize(n, -1); } int find(int k){ if(par[k] == -1) return k; return par[k] = find(par[k]); } void unite(int a, int b){ a = find(a), b = find(b); if(a == b) return; par[a] = b; } }; lint plan_roller_coaster(vector<int> s_in, vector<int> t_in){ int n = int(s_in.size()); n++; int a[n], b[n]; rep(i, n - 1){ a[i] = s_in[i]; b[i] = t_in[i]; } a[n - 1] = 1e9 + 100; b[n - 1] = 1; vector<int> nums; rep(i, n){ nums.push_back(a[i]); nums.push_back(b[i]); } sort(all(nums)); nums.erase(unique(all(nums)), nums.end()); int sz = int(nums.size()); vector<int> deg(sz, 0); rep(i, n){ int a_idx = int(lower_bound(all(nums), a[i]) - nums.begin()); int b_idx = int(lower_bound(all(nums), b[i]) - nums.begin()); deg[a_idx]--; deg[b_idx]++; } int sum = deg[0]; vector<int> big_light(sz - 1); rep(i, sz - 1){ big_light[i] = sum; sum += deg[i]; } rep(i, sz - 1){ if(big_light[i] < 0){ return 1; } } return 0; } // int main(){ // // vector<int> s{1, 4, 5, 6}; // // vector<int> t{7, 3, 8, 6}; // // cout << plan_roller_coaster(s, t) << endl; // 3 // vector<int> s{1, 5, 3}; // vector<int> t{4, 2, 6}; // cout << plan_roller_coaster(s, t) << endl; // 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...