Submission #1078075

#TimeUsernameProblemLanguageResultExecution timeMemory
1078075c2zi6Overtaking (IOI23_overtaking)C++17
39 / 100
3556 ms600 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "overtaking.h" VI W, S; VL T; int m; ll expected(int i, int j) { /* * i-rd avtobusin inchqan jamanak e petq * (j-1)-rd stanciaic j-rd stancia hasnelu hamar */ return 1ll * W[i] * (S[j] - S[j-1]); } VL step(VL t, int j) { int n = t.size(); /* * t[i]-n i-rd avtobusi (j-1)-rd stancia * hasnelu jamanakn e, petq everadardznel ret, * urdex ret[i]-n i-rd avtobusi j-rd stancia * hasnelu jamanakn e */ VL e(n); rep(i, n) e[i] = t[i] + expected(i, j); vector<tuple<ll, ll, int>> a(n); rep(i, n) a[i] = {t[i], e[i], i}; sort(all(a)); ll maxexp = 0; VL ret(n); for (auto[t, e, i] : a) { setmax(maxexp, e); ret[i] = maxexp; } return ret; } void init(int L, int N, VL T_ARG, VI W_ARG, int X, int M, VI S_ARG) { W = W_ARG; W.pb(X); m = M; S = S_ARG; T = T_ARG; } ll arrival_time(ll Y) { VL cur = T; cur.pb(Y); replr(i, 1, m-1) { cur = step(cur, i); /*for (ll x : cur) cout << x << " "; cout << endl;*/ } return cur.back(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...