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;
long long speed;
vector<vector<long long>> ta;
vector<int> ss;
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;
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;i++) {
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]=min(ta[i][idxx[k].second], ta[i][idxx[k-1].second]);
}
}
}
}
long long arrival_time(long long Y) {
long long pr=Y;
long long cur=pr;
for(int i = 1;i<ta.size();i++) {
cur+=(ss[i]-ss[i-1])*speed;
for(int j = 0;j<ta[i].size();j++) {
if(ta[i-1][j]<pr)cur=max(cur, ta[i][j]);
}
pr=cur;
}
return cur;
}
Compilation message (stderr)
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i = 1;i<ta.size();i++) {
| ~^~~~~~~~~~
overtaking.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int j = 0;j<ta[i].size();j++) {
| ~^~~~~~~~~~~~~
# | 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... |