# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897862 | batmendbar | Overtaking (IOI23_overtaking) | C++17 | 3542 ms | 696 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 "overtaking.h"
#include<bits/stdc++.h>
using namespace std;
struct Car {
Car(int speed, long long cur_time, int number) : speed{speed}, cur_time{cur_time}, number{number} {}
int number;
int speed;
long long cur_time;
bool operator<(const Car &other) const{
if (cur_time != other.cur_time) {
return cur_time > other.cur_time;
} else {
return speed > other.speed;
}
}
};
vector<Car> cars;
vector<int> stations;
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
for (int i = 0; i < N; i++) {
cars.push_back(Car(W[i], T[i], i));
}
cars.push_back(Car(X, 0, N));
stations = S;
stations.push_back(L);
return;
}
long long arrival_time(long long Y)
{
cars.back().cur_time = Y;
auto cars1 = cars;
// for (Car c : cars1) {
// cout << c.cur_time << ' ' << c.speed << '\n';
// }
for (int i = 0; i < stations.size(); i++) {
long long dist;
if (i == 0) {
continue;
} else {
dist = stations[i] - stations[i-1];
}
sort(cars1.begin(), cars1.end());
vector<Car> temp;
long long slowest_time = -1;
while(!cars1.empty()) {
slowest_time = max(slowest_time, cars1.back().cur_time + dist * cars1.back().speed);
cars1.back().cur_time = slowest_time;
temp.push_back(cars1.back());
cars1.pop_back();
}
cars1 = temp;
}
for (auto car : cars1) {
if (car.number == cars1.size() - 1) {
return car.cur_time;
}
}
return 0;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |