Submission #713752

#TimeUsernameProblemLanguageResultExecution timeMemory
713752AstraytMeetings (IOI18_meetings)C++17
0 / 100
2587 ms505308 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] + c; } for(int j = i + 1, c = H[i]; j < N; ++j){ c = max(c, H[j]); cost[i][j] = cost[i][j - 1] + 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] + H[j] + cost[j][R[i]]; ans = min(ans, C); } 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...