Submission #836477

#TimeUsernameProblemLanguageResultExecution timeMemory
836477IS_RushdiMeetings (IOI18_meetings)C++17
0 / 100
1805 ms504524 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) { long long q = L.size(); long long n = H.size(); vector<long long > ans(q); vector<vector<long long >> mn(n,vector<long long>(n,1e18)); for(long long i = 0; i < n; i++){ mn[i][i] = H[i]*1ll; long long curr = H[i]; for(long long j = i-1; j >= 0; j--){ curr = min(curr,H[j]*1ll); mn[j][i] = curr; }curr = H[i]; for(long long j = i+1; j < n; j++){ curr = min(curr,H[j]*1ll); mn[j][i] = curr; } } for(long long i = 0; i < n; i++){ for(long long j = 1; j < n; j++){ mn[j][i] += mn[j-1][i]; } } for(long long v = 0; v < q; v++){ long long l = L[v]; long long r = R[v]; long long cnt = 1e18; for(long long 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...