이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define sz(x) (ll)x.size()
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
#define INF 1000000000000000000
#define ins insert
ll plan_roller_coaster(vector <int> ss, vector<int> tt) {
ll n = sz(ss);
vi s(n), t(n);
for(ll i =0; i<n; i++){
s[i] = ss[i];
t[i] = tt[i];
}
set <ii> set_s;
for (ll i =0; i<sz(s); i++){
set_s.ins(ii(s[i], i));
}
ll prevIdx = 0, prevBound = t[0];
ll f = -1;
while (!set_s.empty()){
set <ii> :: iterator it = set_s.lower_bound(ii(prevBound,0));
if (it == set_s.end()){
f = prevIdx;
break;
}
prevBound = it->F;
prevIdx = t[it->S];
set_s.erase(it);
}
if (set_s.empty()){
return 1;
}
else{
set_s.clear();
for (ll i =0; i<sz(s); i++){
if (i != f);
set_s.ins(ii(s[i], i));
}
prevIdx = 0, prevBound = t[0];
while (!set_s.empty()){
set <ii> :: iterator it = set_s.lower_bound(ii(prevBound,0));
if (it == set_s.end()){
break;
}
prevBound = it->F;
prevIdx = t[it->S];
set_s.erase(it);
}
if (set_s.empty() && s[f] >= prevBound){
return 1;
}
}
return 0;
}
/*
4 1
1 7
4 3
5 8
6 6
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |