Submission #836470

#TimeUsernameProblemLanguageResultExecution timeMemory
836470IS_RushdiMeetings (IOI18_meetings)C++17
0 / 100
1811 ms504612 KiB
//#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define ll long long vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) { int q = L.size(); int n = H.size(); vector<ll> ans(q); vector<vector<ll>> mn(n,vector<ll>(n,1e18)); for(int i = 0; i < n; i++){ mn[i][i] = H[i]; int curr = H[i]; for(int j = i-1; j >= 0; j--){ curr = min(curr,H[j]); mn[j][i] = curr; }curr = H[i]; for(int j = i+1; j < n; j++){ curr = min(curr,H[j]); mn[j][i] = curr; } } for(int i = 0; i < n; i++){ for(int j = 1; j < n; j++){ mn[j][i] += mn[j-1][i]; } } for(int v = 0; v < q; v++){ int l = L[v]; int r = R[v]; ll cnt = 1e18; for(int i = l; i <= r; i++){ if(l == 0)cnt = min(cnt,mn[r][i]); else cnt = min(cnt,mn[r][i]-mn[l-1][i]); } ans[v] = cnt; } return ans; } // int main(){ // }
#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...