# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
24385 | 2017-06-06T12:57:54 Z | gs14004 | Roller Coaster Railroad (IOI16_railroad) | C++11 | 0 ms | 0 KB |
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pi; map<int, int> mp; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { vector<int> v; int n = (int) s.size(); for(int i=0; i<n; i++){ mp[s[i]]++; mp[e[i]]--; } for(auto &i : mp) v.push_back(i.second); int curBef = 1; for(int i=0; i<v.size(); i++){ if(v[i] > 0){ curBef -= v[i]; if(curBef < 0) return 0 } curBef -= v[i]; } return 0; }