제출 #841889

#제출 시각아이디문제언어결과실행 시간메모리
841889hcng추월 (IOI23_overtaking)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "overtaking.h" using namespace std; #define long long long long l, n, x, m; vector<long> w, s; vector<vector<long>> t, e, v, pre; bool flag; void init(int L, int N, vector<long> T, vector<int> W, int X, int M, vector<int> S) { l = L, x = X, m = M; s.assign(S.begin(), S.end()); t.resize(m); for (int i = 0; i < N; i++) { if (W[i] > X) { w.push_back(W[i]); t[0].push_back(T[i]); } } n = w.size(); if (n == 0) { flag = true; return; } w.push_back(X); t[0].push_back(0); e.assign(m, vector<long>(n + 1)); v.assign(m, vector<long>(n)); pre.assign(m, vector<long>(n)); for (long i = 1; i < m; i++) { t[i] = vector<long>(n + 1); for (long j = 0; j < n; j++) { v[i][j] = j; e[i][j] = t[i - 1][j] + w[j] * (s[i] - s[i - 1]); } sort(v[i].begin(), v[i].end(), [&](const long &a, const long &b) { return t[i - 1][a] < t[i - 1][b]; } ); pre[i][0] = e[i][v[i][0]]; for (long j = 1; j < n; j++) { pre[i][j] = max(e[i][v[i][j]], pre[i][j - 1]); } for (long j = 0; j < n; j++) { long L = 0, R = j - 1; while (L < R) { M = (L + R + 1) / 2; if (t[i - 1][v[i][M]] < t[i - 1][v[i][j]]) L = M; else R = M - 1; } if (t[i - 1][v[i][j]] == t[i - 1][v[i][0]]) t[i][v[i][j]] = e[i][v[i][j]]; else t[i][v[i][j]] = max(e[i][v[i][j]], pre[i][L]); } } } long arrival_time(long y) { if (flag) { return w[n] * l; } t[0][n] = y; for (long i = 1; i < m; i++) { e[i][n] = t[i - 1][n] + w[n] * (s[i] - s[i - 1]); long L = 0, R = n - 1; while (L < R) { long M = (L + R + 1) / 2; if (t[i - 1][v[i][M]] < t[i - 1][n]) L = M; else R = M - 1; } if (t[i - 1][n] <= t[i - 1][v[i][0]]) t[i][n] = e[i][n]; else t[i][n] = max(e[i][n], pre[i][L]); } 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...