제출 #1078231

#제출 시각아이디문제언어결과실행 시간메모리
1078231c2zi6추월 (IOI23_overtaking)C++17
39 / 100
3522 ms16848 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" int n; 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]); } typedef vector<tuple<ll, ll, int>> VLLI; VLLI a; 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); a = VLLI(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; } struct BESTCHOICE { int n; VL times, values; BESTCHOICE(){} BESTCHOICE(VLLI a) { n = a.size(); times = values = VL(); for (auto[t, e, i] : a) { times.pb(t); values.pb(e); } } ll operator()(ll x) { int ind = -1; rep(i, n) { if (times[i] < x) ind = i; else break; } ll ret = 0; replr(i, 0, ind) setmax(ret, values[i]); return ret; } void print() { for (ll x : times) cout << x << " "; cout << endl; for (ll x : values) cout << x << " "; cout << endl; } }; vector<BESTCHOICE> best; void init(int L, int N_ARG, VL T_ARG, VI W_ARG, int X, int M, VI S_ARG) { n = N_ARG; W = W_ARG; W.pb(X); m = M; S = S_ARG; T = T_ARG; VL cur = T; replr(i, 1, m-1) { cur = step(cur, i); best.pb(BESTCHOICE(a)); } } ll arrival_time(ll Y) { replr(i, 1, m-1) { auto& p = best[i-1]; /*cout << "Kancinq hetevyal bani mijov" << endl;*/ /*p.print();*/ /*cout << "Expected@ " << Y + expected(n, i) << endl;*/ Y = max(Y + expected(n, i), p(Y)); /*cout << "Y dardzav " << Y << endl;*/ /*cout << endl;*/ } return Y; }
#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...