#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
#define node pair<pair<ll,ll>,ll>
using namespace std;
using ll = long long;
const ll N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;
int n , l , m , x , s[N];
vector<node> vec;
void init(int L, int N, vector<long long> T, vector<int> W, int X, int M, vector<int> S){
n = N; l = L; x = X; m = M;
for(int i = 0; i < n; i++){
vec.push_back({{T[i],W[i]},i});
}
for(int i = 0; i < m; i++){
s[i] = S[i];
}
return;
}
long long arrival_time(long long Y){
vector<node> v;
for(int i = 0; i < vec.size(); i++) v.push_back(vec[i]);
v.push_back({{Y,x},vec.size()});
for(int i = 1; i < m; i++){
sort(all(v),[&](node a , node b){
if(a.F.F == b.F.F) {
if(a.F.S < b.F.S) {
// cout << a.S <<" " << b.S << " 1\n";
return 1;
}
else {
// cout << a.S <<" " << b.S << " 2\n";
return 0;
}
} else {
if(a.F.F < b.F.F){
// cout << a.S <<" " << b.S << " 3\n";
return 1;
}
else {
// cout << a.S <<" " << b.S << " 4\n";
return 0;
}
}
});
ll cur = 0;
for(int j = 0; j < v.size(); j++){
// cout << v[j].F.F << " " << v[j].F.S << "\n";
cur = max(cur , v[j].F.F+v[j].F.S*(s[i]-s[i-1]));
v[j].F.F = cur;
}
// cout << "\n";
}
for(int i = 0; i < v.size(); i++){
if(v[i].S == vec.size()){
return v[i].F.F;
}
}
}
// int main()
// {
// int L, N, X, M, Q;
// assert(5 == scanf("%d %d %d %d %d", &L, &N, &X, &M, &Q));
// std::vector<long long> T(N);
// for (int i = 0; i < N; i++)
// assert(1 == scanf("%lld", &T[i]));
// std::vector<int> W(N);
// for (int i = 0; i < N; i++)
// assert(1 == scanf("%d", &W[i]));
// std::vector<int> S(M);
// for (int i = 0; i < M; i++)
// assert(1 == scanf("%d", &S[i]));
// std::vector<long long> Y(Q);
// for (int i = 0; i < Q; i++)
// assert(1 == scanf("%lld", &Y[i]));
//
// fclose(stdin);
//
// init(L, N, T, W, X, M, S);
// std::vector<long long> res(Q);
// for (int i = 0; i < Q; i++)
// res[i] = arrival_time(Y[i]);
//
// for (int i = 0; i < Q; i++)
// printf("%lld\n", res[i]);
// fclose(stdout);
// return 0;
// }
Compilation message (stderr)
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
69 | }
| ^
# | 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... |