Submission #1057889

#TimeUsernameProblemLanguageResultExecution timeMemory
1057889shmaxOvertaking (IOI23_overtaking)C++17
0 / 100
0 ms348 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; using i32 = int; #define int long long #define len(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define inf 1000'000'000 template<typename T> using vec = vector<T>; template<typename T> using graph = vec<vec<T>>; namespace Params { int L, N; vec<int> T, W; int X, M; vec<int> S; } vec<vec<int>> e; void init(i32 L, i32 N, std::vector<int> T, std::vector<i32> W, i32 X, i32 M, std::vector<i32> S) { Params::L = L; Params::N = N; Params::T = T; Params::W.resize(N); for (int i = 0; i < N; i++) { Params::W[i] = W[i]; } Params::X = X; Params::M = M; Params::S.resize(M); for (int i = 0; i < M; i++) { Params::S[i] = S[i]; } e.resize(N, vec<int>(M, 0)); for (int i = 0; i < N; i++) { e[i][0] = T[i]; } for (int j = 1; j < M; j++) { vec<int> ord(N); iota(all(ord), 0); sort(all(ord), [&](int x, int y) { return e[x][j - 1] < e[y][j - 1]; }); int before = 0; int cur = 0; for (int k = 0; k < len(ord); k++) { if (k != 0) { if (e[k][j - 1] != e[k - 1][j - 1]) { before = max(before, cur); cur = 0; } } int i = ord[k]; e[i][j] = max(e[i][j - 1] + (S[j] - S[j - 1]) * W[i], before); cur = max(cur, e[i][j]); } } } int arrival_time(int Y) { int cur_time = Y; for (int j = 1; j < Params::M; j++) { int time = 0; for (int i = 0; i < Params::N; i++) { if (e[i][j - 1] < cur_time) time = max(time, e[i][j]); } time = max(time, cur_time + (Params::S[j] - Params::S[j - 1]) * Params::X); cur_time = time; } return cur_time; }
#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...