이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<ii> vii;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define RE(a,b) REP(a,0,b)
#define RE1(a,b) REP(a,1,b+1)
#define FOR(a,b) for(auto& a : b)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
vll minimum_costs(vi H, vi L, vi R) {
int n = H.size();
int q = L.size();
vector<vll> costL, costR;
RE(i,2) (i?costL:costR).assign(n,vll(n,0));
RE(i,n) {
ll mx = 0;
ll res = 0;
REP(j,i,n) {
mx = max<ll>(mx,H[j]);
res += mx;
costL[i][j] = res;
}
mx = res = 0;
REV(j,0,i+1) {
mx = max<ll>(mx,H[j]);
res += mx;
costR[i][j] = res;
}
}
vll C(q,1e18);
RE(cq,q) {
int l=L[cq], r=R[cq];
REP(i,l,r+1) {
C[cq] = min(C[cq], costR[i][l] + costL[i][r] - H[i]);
}
}
return C;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |