제출 #282220

#제출 시각아이디문제언어결과실행 시간메모리
282220FashoRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
295 ms23288 KiB
#include <bits/stdc++.h> #define N 200005 #define ll long long int #define fo(i,x,y) for(int i=x;i<=y;i++) #define fs(ar,n) fo(i,1,n) cin>>ar[i] #define sp " " #define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) #define pb push_back #define ppb pop_back #define fi first #define se second #define ii pair<int,int> #define lli pair<ll,ll> #define mod 1000000007 #include "railroad.h" using namespace std; ll m,ar[N],sum,t; lli p[N]; multiset<lli> st; multiset<lli>::iterator it; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { ll n = (int) s.size(); fo(i,1,n) { p[i]={s[i-1],t[i-1]}; st.insert(p[i]); } ll last=0; ll cnt=0; lli x={0,0}; lli tutmac={0,0}; fo(i,1,n) { it=st.lower_bound({last,0}); lli tut=*it; if(!st.count(*it) || tut.fi<last) { // cerr<<i<<sp<<last<<sp<<tut.fi<<sp<<tut.se<<endl; return 1; } x=*it; st.erase(it); if(cnt) { last=x.se; continue; } it=st.lower_bound({last,0}); tut=*it; if(!st.count(*it) || tut.fi<last) { cnt++; tutmac=x; continue; } last=x.se; // ll x=*it.se; } // cout<<endl; // cout<<tutmac.fi<<sp<<tutmac.se<<endl;; lli bos={0,0}; if(tutmac==bos) return 0; if(tutmac.fi>=last) return 0; return 1; } // int main() { // 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; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...