This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define IDB pair <db,int>
#define TII pair <treap*,treap*>
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
using namespace std;
#include "railroad.h"
ll plan_roller_coaster(vector <int> s,vector <int> t)
{
set <int> val;
map <int,int> U,D;
int i;
for(i=0;i<s.size();i++)
{
val.insert(s[i]); val.insert(t[i]);
if(s[i]<=t[i]) U[s[i]]++,U[t[i]]--;
else D[t[i]]++,D[s[i]]--;
}
val.insert(1);
int up=0,down=0;
for(int x:val)
{
up+=U[x]; down+=D[x];
if(up>down) return 1;
}
return 0;
}
/*
int main()
{
freopen("railroad.inp","r",stdin);
freopen("railroad.out","w",stdout);
vector <int> s,t;
int l,r;
while(cin>>l>>r) s.push_back(l),t.push_back(r);
cout<<plan_roller_coaster(s,t);
}
*/
Compilation message (stderr)
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(i=0;i<s.size();i++)
| ~^~~~~~~~~
# | 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... |