제출 #713758

#제출 시각아이디문제언어결과실행 시간메모리
713758Astrayt모임들 (IOI18_meetings)C++17
0 / 100
2501 ms504608 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { int N = H.size(), Q = L.size(); vector<long long> A(Q); vector<vector<long long>> cost(N, vector<long long>(N, 0)); for(int i = 0; i < N; ++i){ for(int j = i - 1, c = H[i]; j >= 0; --j){ c = max(c, H[j]); cost[j][i] = cost[j + 1][i] + 1ll * c; } for(int j = i + 1, c = H[i]; j < N; ++j){ c = max(c, H[j]); cost[i][j] = cost[i][j - 1] + 1ll * c; } } for(int i = 0; i < Q; ++i){ long long ans = 1e18; for(int j = L[i]; j <= R[i]; ++j){ long long C = cost[L[i]][j] + 1ll * H[j] + cost[j][R[i]]; ans = min(ans, C); } assert(ans > 0); A[i] = ans; } return A; }
#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...