Submission #1022705

#TimeUsernameProblemLanguageResultExecution timeMemory
1022705thinknoexitOvertaking (IOI23_overtaking)C++17
19 / 100
6 ms8540 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1010; struct A { ll t, s; int idx; bool operator < (const A& o) const { return t < o.t; } } a[N][N]; ll pref[N][N], s[N]; bool ch[N]; int n, m; ll X; void init(int L, int NN, vector<ll> T, vector<int> W, int X, int M, vector<int> S) { n = NN; m = M; ::X = X; for (int i = 0;i < m;i++) { s[i] = S[i]; } for (int i = 0;i < n;i++) { a[0][i] = { T[i], W[i], i }; } for (int K = 0;K < m - 1;K++) { sort(a[K], a[K] + n); int idx = 0; ll mx = 0; for (int i = 0, j;i < n;i = j) { for (j = i;j < n && a[K][i].t == a[K][j].t;j++) { pref[K][j] = mx; a[K + 1][idx++] = { max(a[K][j].t + a[K][j].s * (s[K + 1] - s[K]), mx) , a[K][j].s, a[K][j].idx }; } for (j = i;j < n && a[K][i].t == a[K][j].t;j++) { mx = max(mx, a[K][j].t + a[K][j].s * (s[K + 1] - s[K])); } } } sort(a[m - 1], a[m - 1] + n); } ll arrival_time(ll Y) { memset(ch, 0, sizeof ch); ll now = Y; for (int i = 0;i < m - 1;i++) { ll e = now + X * (s[i + 1] - s[i]); ll mx = e; for (int j = 0;j < n;j++) { if (!ch[a[i][j].idx] && a[i][j].t < now && a[i][j].t + a[i][j].s * (s[i + 1] - s[i]) > e) { mx = max(mx, a[i][j].t + a[i][j].s * (s[i + 1] - s[i])); ch[a[i][j].idx] = 1; } } now = mx; } return now; }
#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...