# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061389 | tolbi | Overtaking (IOI23_overtaking) | C++17 | 3554 ms | 34124 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;
#define int long long
vector<vector<array<int,3>>> bus;
vector<vector<int>> hsh;
vector<int> S;
int X;
void init(int32_t L, int32_t N, std::vector<long long> T, std::vector<int32_t> W, int32_t X, int32_t M, std::vector<int32_t> S)
{
::X=X;
::S.resize(S.size());
for (int i = 0; i < S.size(); i++) ::S[i]=S[i];
bus.push_back(vector<array<int,3>>());
hsh.push_back(vector<int>(N));
for (int i = 0; i < N; i++){
bus.back().push_back({T[i],W[i],i});
}
sort(bus.back().begin(), bus.back().end());
for (int i = 1; i < M; i++){
bus.push_back(bus.back());
int pmax = 0;
for (int j = 0; j < N; j++){
bus.back()[j][0]+=bus.back()[j][1]*(::S[i]-::S[i-1]);
pmax=max(pmax,bus.back()[j][0]);
bus.back()[j][0]=pmax;
}
sort(bus.back().begin(), bus.back().end());
for (int j = 0; j < bus.back().size(); j++){
hsh.back()[bus.back()[j][2]]=j;
}
if (i!=M-1){
hsh.push_back(hsh.back());
}
}
}
int arrival_time(int Y)
{
pair<int,int> bne = {Y,X};
for (int i = 0; i < S.size()-1; i++){
int bendenkuc = -1;
auto it = lower_bound(bus[i].begin(), bus[i].end(), array<int,3>{bne.first,0,0});
if (it!=bus[i].begin()){
it--;
bendenkuc = hsh[i][(*it)[2]];
}
if (bendenkuc==-1){
bne.first+=bne.second*(S[i+1]-S[i]);
}
else {
bne.first=max(bne.first+bne.second*(S[i+1]-S[i]),bus[i+1][bendenkuc][0]);
}
}
return bne.first;
}
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... |