# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857356 | resting | Overtaking (IOI23_overtaking) | C++17 | 0 ms | 0 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.
restrictions[i];
int p1 = l1.size() - 1;
int p2 = l2.size() - 1;
int cur = 100000;
while (p1 >= 0 || p2 >= 0) {
// cout<<"A: "<<p1<<","<<p2<<endl;
if (p1 < 0) {
nice.push_back(l2[p2]);
cur = l2[p2].first;
p2--;
} else if (p2 < 0) {
nice.push_back(l1[p1]);
cur = l1[p1].first;
p1--;
} else if (l1[p1].second < l2[p2].second) {
int a = l2[p2].first;
while (l1[p1].second >= l2[p2].first) {
a = min(a, l1[p1].first);
p1--;
}
l2[p2].first = a;
nice.push_back(l2[p2]);
cur = l2[p2].first;
p2--;
} else {
assert(l1[p1].second >= l2[p2].second);
nice.push_back(l1[p1]);
cur = l1[p1].first;
p1--;
}
while (p1 >= 0 && l1[p1].first >= cur) p1--;
while (p2 >= 0 && l2[p2].first >= cur) p2--;
}
swap(restriction, nice);
//reverse(restriction.begin(), restriction.end());
sort(restriction.begin(), restriction.end(), comp);
// cout<<"restriction"<<endl;
// for(auto &x : restriction) cout<<x.first<<" "<<x.second<<endl;
}
return;
}
long long arrival_time(long long Y)
{
auto yes = prev(upper_bound(restriction.begin(), restriction.end(), make_pair( Y, numeric_limits<long long>::max() )))- restriction.begin();
if (yes >= 0 && yes <= restriction.size()) Y = max(Y, restriction[yes].second);
return Y + x * l;
}