Submission #615284

#TimeUsernameProblemLanguageResultExecution timeMemory
615284Minindu2006Meetings (IOI18_meetings)C++17
19 / 100
3496 ms786432 KiB
#include "meetings.h" #include <bits/stdc++.h> #define ll long long using namespace std; vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { int n = H.size(), q = L.size(); ll cost[n][n]; // cost from ith to jth for(int i=0;i<n;i++) { cost[i][i] = H[i]; for(int k=i-1;k>=0;k--) cost[i][k] = max(cost[i][k + 1], (ll)H[k]); for(int k=i+1;k<n;k++) cost[i][k] = max(cost[i][k - 1], (ll)H[k]); for(int k=1;k<n;k++) cost[i][k] += cost[i][k - 1]; } vector<ll> res; for(int i=0;i<q;i++) { ll ans = LLONG_MAX; for(int k=L[i];k<=R[i];k++) ans = min(ans, (L[i] > 0 ? cost[k][R[i]] - cost[k][L[i] - 1] : cost[k][R[i]])); res.push_back(ans); } return res; }
#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...