Submission #1045224

#TimeUsernameProblemLanguageResultExecution timeMemory
1045224woodMeetings (IOI18_meetings)C++17
0 / 100
0 ms348 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) { int Q = L.size(); std::vector<long long> C(Q); int n = H.size(); long long sum[n][n]; memset(sum,0,sizeof sum); for(int i = 0; i<n; i++){ int mx = H[i]; for(int j = i; j>=0; j--){ mx = max(mx,H[j]); if(j<i) sum[i][j]= sum[i][j+1]+mx; else sum[i][j] = mx; } mx = H[i]; for(int j = i+1; j<n; j++){ mx = max(mx,H[j]); if(j>i+1) sum[i][j] = sum[i][j-1]+mx; else sum[i][j] = mx; } } for (int j = 0; j < Q; ++j) { long long res = LLONG_MAX; for(int i = L[j]; i<=R[j]; i++) res = min(res,sum[i][L[j]]+sum[i][R[j]]); C[j] = res; } return C; }
#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...