제출 #1019854

#제출 시각아이디문제언어결과실행 시간메모리
1019854overwatch9모임들 (IOI18_meetings)C++17
0 / 100
361 ms786432 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> 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>> mx(n, vector <ll> (n)); vector <vector <ll>> mx2(n, vector <ll> (n)); for (int i = 0; i < n; i++) { mx[i][i] = h[i]; mx2[i][i] = h[i]; ll x = h[i]; for (int j = i+1; j < n; j++) { mx[i][j] = max(x, (ll)h[j]); x = mx[i][j]; mx[i][j] += mx[i][j-1]; } x = h[i]; for (int j = i-1; j >= 0; j--) { mx2[i][j] = max(x, (ll)h[j]); mx2[i][j] += mx2[i][j+1]; } } for (int i = 0; i < Q; i++) { ans[i] = 1e18; for (int j = L[i]; j <= R[i]; j++) { ll x = mx2[j][L[i]] + mx[j][R[i]] - h[j]; ans[i] = min(ans[i], x); // cout << x << ' '; } } // cout << '\n'; return ans; }
#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...