Submission #769038

#TimeUsernameProblemLanguageResultExecution timeMemory
769038SanguineChameleonMeetings (IOI18_meetings)C++17
4 / 100
54 ms92980 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; const long long inf = 1e18L + 20; long long sum_l[3020][3020]; long long sum_r[3020][3020]; vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { int N = H.size(); int Q = L.size(); if (N <= 3000) { for (int i = 0; i < N; i++) { int mx = 0; long long sum = 0; for (int j = i; j >= 0; j--) { mx = max(mx, H[j]); sum += mx; sum_l[j][i] = sum; } mx = 0; sum = 0; for (int j = i; j < N; j++) { mx = max(mx, H[j]); sum += mx; sum_r[i][j] = sum; } } vector<long long> res(Q, inf); for (int i = 0; i < Q; i++) { for (int j = L[i]; j <= R[i]; j++) { res[i] = min(res[i], sum_l[L[i]][j] + sum_r[j][R[i]] - H[j]); } } return res; } return vector<long long>(); }
#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...