# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021972 | parsadox2 | Roller Coaster Railroad (IOI16_railroad) | C++17 | 83 ms | 13764 KiB |
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 "railroad.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10 , inf = 1e9 + 10;
int n;
struct item{
int val , ty , id;
};
bool cmp(item aa , item bb)
{
if(aa.val != bb.val)
return aa.val < bb.val;
return aa.ty < bb.ty;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
vector <item> vec;
n = s.size();
for(int i = 0 ; i < n ; i++)
{
//cout << s[i] << " : " << t[i] << endl;
vec.push_back({t[i] , 0 , i});
vec.push_back({s[i] , 1 , i});
}
vec.push_back({1 , 0 , -1});
vec.push_back({inf , 1 , n});
sort(vec.begin() , vec.end() , cmp);
int sum = 0 , ty = 0 , las_bad = 10 , need_to_check = -1 , ans = 0;
for(int i = 0 ; i < vec.size() ; i++)
{
auto u = vec[i];
las_bad++;
int now = (u.ty == 0 ? 1 : -1);
sum += now;
if(sum == 0)
{
if(las_bad == 2 && vec[i].id == vec[i - 1].id)
ans = 69;
las_bad = 0;
}
if(sum < 0)
ans = 69;
//cout << i << " " << sum << " " << u.ty << " " << now << " " << las_bad << endl;
}
return ans;
}
/*
4
1 7
4 3
5 8
6 6
*/
Compilation message (stderr)
# | 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... |