제출 #1069203

#제출 시각아이디문제언어결과실행 시간메모리
1069203Dan4Life모임들 (IOI18_meetings)C++17
19 / 100
412 ms621028 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using vi = vector<int>; using vll = vector<ll>; using ar2 = array<int,2>; const int INF = (int)1e9; const ll LINF = (ll)2e18; const int mxN = (int)5e3+10; int n, q; vi a; ll le[mxN][mxN], ri[mxN][mxN]; vll minimum_costs(vi A, vi L, vi R) { n = sz(A); q = sz(L); a = A; for(int i = 0; i < n; i++){ int cur = 0; for(int j = i; j < n; j++) cur = max(cur,a[j]), ri[i][j]=(j?ri[i][j-1]:0ll)+(ll)cur; cur = 0; for(int j = i; j>=0; j--) cur = max(cur,a[j]), le[i][j]+=le[i][j+1]+(ll)cur; } vll ans(q,LINF); for(int i = 0; i < q; i++){ int l = L[i], r = R[i]; for(int j = l; j <= r; j++) ans[i]=min(ans[i],le[j][l]+ri[j][r]-(ll)a[j]); } 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...