This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
www.youtube.com/YugiHackerChannel
linktr.ee/YugiHacker
*/
#ifndef function_only
#include "overtaking.h"
#endif // function_only
#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn 1003
using namespace std;
int l, n, w[maxn], x, m, s[maxn];
long long t[maxn], y;
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
l = L, n = N;
for (int i=0; i<n; i++) t[i] = T[i];
for (int i=0; i<n; i++) w[i] = W[i];
x = X;
m = M;
for (int i=0; i<m; i++) s[i] = S[i];
}
namespace sub1 {
long long arr_time[2][maxn];
long long solve() {
t[n] = y;
w[n] = x;
for (int i=0; i<2; i++) arr_time[i][0] = t[i];
//cout << m; el;
//f0 (i, m) cout << s[i] << ' '; el;
for (int i=1; i<m; i++)
{
for (int x=0; x<2; x++)
{
arr_time[x][i] = arr_time[x][i-1] + 1ll * (s[i] - s[i-1]) * w[x];
}
//cout << arr_time[0][i] << ' ' << arr_time[1][i], el;
for (int x=0; x<2; x++) {
if (arr_time[x][i-1] > arr_time[x^1][i-1] && arr_time[x][i] < arr_time[1^x][i])
arr_time[x][i] = arr_time[1^x][i];
}
//cout << arr_time[1][i] << ' '; el;
}
return arr_time[1][m-1];
}
}
long long arrival_time(long long Y) {
y = Y;
if (n == 1) return sub1::solve();
}
#ifdef function_only
main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int l, n, x, m, q; cin >> l >> n >> x >> m >> q;
vector <long long> t(n);
vector <int> w(n);
vector <int> s(m);
for (int i=0; i<n; i++) cin >> t[i];
for (int i=0; i<n; i++) cin >> w[i];
for (int i=0; i<m; i++) cin >> s[i];
init(l, n, t, w, x, m, s);
while (q--) {
long long y; cin >> y;
cout << arrival_time(y) << '\n';
}
}
#endif // function_only
Compilation message (stderr)
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
61 | }
| ^
# | 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... |