제출 #966534

#제출 시각아이디문제언어결과실행 시간메모리
966534nguyentunglam추월 (IOI23_overtaking)C++17
39 / 100
3535 ms604 KiB
#include "overtaking.h" #include<bits/stdc++.h> using namespace std; const int N = 1010; int n, m; int order[N]; long long t[N], w[N], s[N], f[N]; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { n = N; m = M; for(int i = 0; i < n; i++) w[i] = W[i], t[i] = T[i]; for(int i = 0; i < m; i++) s[i] = S[i]; w[n] = X; for(int i = 0; i <= n; i++) order[i] = i; } long long arrival_time(long long Y) { for(int i = 0; i <= n; i++) f[i] = t[i]; f[n] = Y; for(int j = 1; j < m; j++) { sort(order, order + n + 1, [] (const int &x, const int &y) { if (f[x] != f[y]) return f[x] < f[y]; return w[x] < w[y]; }); long long slowest = 0; for(int cur = 0; cur <= n; cur++) { int i = order[cur]; f[i] = max(slowest, f[i] + w[i] * (s[j] - s[j - 1])); slowest = f[i]; } } return f[n]; } #ifdef ngu int main() { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); int L, N, X, M, Q; assert(5 == scanf("%d %d %d %d %d", &L, &N, &X, &M, &Q)); std::vector<long long> T(N); for (int i = 0; i < N; i++) assert(1 == scanf("%lld", &T[i])); std::vector<int> W(N); for (int i = 0; i < N; i++) assert(1 == scanf("%d", &W[i])); std::vector<int> S(M); for (int i = 0; i < M; i++) assert(1 == scanf("%d", &S[i])); std::vector<long long> Y(Q); for (int i = 0; i < Q; i++) assert(1 == scanf("%lld", &Y[i])); fclose(stdin); init(L, N, T, W, X, M, S); std::vector<long long> res(Q); for (int i = 0; i < Q; i++) res[i] = arrival_time(Y[i]); for (int i = 0; i < Q; i++) printf("%lld\n", res[i]); fclose(stdout); return 0; } #endif // ngu
#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...