Submission #992413

#TimeUsernameProblemLanguageResultExecution timeMemory
992413vqpahmadMeetings (IOI18_meetings)C++14
0 / 100
11 ms2908 KiB
#include<bits/stdc++.h>
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R){
	int q = sz(L), n = sz(H);
	assert(n <= 3000 && q <= 10);
	vector<ll> ans(q, 1e18);
	vector<ll> mid(n);
	for (int i = 0; i < q; i++){
		for (int j = 0; j < n; j++) mid[j] = 0;
		for (int m = L[i]; m <= R[i]; m++){
			int cur = 0;
			for (int j = m; j <= R[i]; j++){
				ckmax(cur, H[j]);
				mid[j] += cur;
			}
			cur = 0;
			for (int j = m - 1; j >= L[i]; j--){
				ckmax(cur, H[j]);
				mid[j] += cur;
			}
		}
		for (int m = L[i]; m <= R[i]; m++){
			ckmin(ans[i], mid[m]);
		}
	}
	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...