Submission #1135553

#TimeUsernameProblemLanguageResultExecution timeMemory
1135553alterio모임들 (IOI18_meetings)C++20
19 / 100
5594 ms4932 KiB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
    int N = H.size(), Q = L.size();
    vector<ll> C(Q);
	for (int i = 0; i < Q; i++) C[i] = 1e17;
	ll ansL[N + 10], ansR[N + 10];
    for (int i = 0; i < N; i++) {
        ll mx = H[i];
		ansL[i] = ansR[i] = H[i];
		for (int j = i + 1; j < N; j++) {
			mx = max(mx, (ll) H[j]);
			ansL[j] = ansL[j - 1] + mx;
		}
		mx = H[i];
		for (int j = i - 1; j >= 0; j--) {
			mx = max(mx, (ll) H[j]);
			ansR[j] = ansR[j + 1] + mx;
		}
		for (int j = 0; j < Q; j++) {
			if (L[j] <= i && i <= R[j]) C[j] = min(C[j], ansR[L[j]] + ansL[R[j]] - H[i]);
		}
    }
    return C;
}
#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...