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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long speed;
vector<vector<long long>> ta;
vector<int> ss;
vector<vector<pair<long long, long long>>> pr;
long long asdf=0;
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) {
speed=X;
asdf=S.back()*speed;
ta=vector<vector<long long>> (M, vector<long long> (N));
ss=S;
for(int i = 0;i<M;i++) {
for(int j = 0;j<N;j++) {
if(i==0)ta[i][j]=T[j];
else ta[i][j]=ta[i-1][j]+(long long)(S[i]-S[i-1])*W[j];
}
if(i){
vector<pair<pair<long long, long long>, int>> idxx;
for(int j = 0;j<N;j++) {
idxx.push_back({{ta[i-1][j], ta[i][j]}, j});
}
sort(idxx.begin(), idxx.end());
for(int k = 1;k<N;k++) {
ta[i][idxx[k].second]=max(ta[i][idxx[k].second], ta[i][idxx[k-1].second]);
}
}
}
pr.resize(M);
for(int i =0 ;i<M;i++) {
for(int j = 0;j<N;j++) {
ta[i][j]-=S[i]*speed;
if(i)
pr[i].push_back({ta[i-1][j], ta[i][j]});
}
}
}
long long arrival_time(long long Y) {
long long ans=Y;
for(int i =0;i<pr.size();i++) {
long long tmp=0;
for(auto j:pr[i]) {
if(j.first < ans)tmp=max(tmp, j.second);
}
ans=max(ans, tmp);
}
return ans+asdf;
}
Compilation message (stderr)
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i =0;i<pr.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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |