제출 #776084

#제출 시각아이디문제언어결과실행 시간메모리
776084Magikarp4000모임들 (IOI18_meetings)C++17
19 / 100
584 ms234844 KiB
#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 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...