Submission #841772

#TimeUsernameProblemLanguageResultExecution timeMemory
841772hcngOvertaking (IOI23_overtaking)C++17
39 / 100
3550 ms16844 KiB
#include <bits/stdc++.h> #include "overtaking.h" using namespace std; #define long long long long l, n, x, m; vector<long> t, w, s; void init(int L, int N, vector<long> T, vector<int> W, int X, int M, vector<int> S) { // copying variables l = L, x = X, m = M; s.assign(S.begin(), S.end()); for (long i = 0; i < N; i++) { if (W[i] > X) { w.push_back(W[i]); t.push_back(T[i]); } } n = w.size(); w.push_back(X); } long arrival_time(long y) { vector<vector<long>> e(m, vector<long>(n + 1)), t(m, vector<long>(n + 1)); for (long i = 0; i < n; i++) { t[0][i] = ::t[i]; } t[0][n] = y; for (long i = 1; i < m; i++) { vector<long> v(n + 1); for (long j = 0; j <= n; j++) { v[j] = j; e[i][j] = t[i - 1][j] + w[j] * (s[i] - s[i - 1]); } sort(v.begin(), v.end(), [&](const long &a, const long &b) { return t[i - 1][a] < t[i - 1][b]; } ); vector<long> pre(n + 1); pre[0] = e[i][v[0]]; for (long j = 1; j <= n; j++) { pre[j] = max(e[i][v[j]], pre[j - 1]); } for (long j = 0; j <= n; j++) { long L = 0, R = j - 1; while (L < R) { long M = (L + R + 1) / 2; if (t[i - 1][v[M]] < t[i - 1][v[j]]) L = M; else R = M - 1; } if (t[i - 1][v[j]] == t[i - 1][v[0]]) t[i][v[j]] = e[i][v[j]]; else t[i][v[j]] = max(e[i][v[j]], pre[L]); } } // for (long i = 0; i <= n; i++) { // for (long j = 0; j < m; j++) { // cerr << e[j][i] << ' ' << t[j][i] << " "; // } // cerr << endl; // } return t[m - 1][n]; }
#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...