이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n'
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;
#define int long long
const int MAXN = 5e3+5;
int n,q;
int h[MAXN], le[MAXN][MAXN], ri[MAXN][MAXN];
PII qu[MAXN];
vector<int> resv;
std::vector<long long> minimum_costs(std::vector<int32_t> H, std::vector<int32_t> L, std::vector<int32_t> R) {
n = H.size(); q = L.size();
FOR(i,0,n) h[i] = H[i];
FOR(i,0,q) qu[i] = {L[i],R[i]};
FOR(i,0,n) {
int ma = h[i];
ri[i][i] = le[i][i] = h[i];
FOR(j,i+1,n) {
ma = max(ma,h[j]);
ri[i][j] = ri[i][j-1]+ma;
}
ma = h[i];
FORR(j,i-1,-1) {
ma = max(ma,h[j]);
le[i][j] = le[i][j+1]+ma;
}
}
FOR(i,0,q) {
int x = qu[i].F, y = qu[i].S;
int res = LLINF;
FOR(j,x,y+1) {
res = min(res, le[j][x]+ri[j][y]-h[j]);
}
resv.PB(res);
}
return resv;
}
# | 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... |