Submission #1069055

#TimeUsernameProblemLanguageResultExecution timeMemory
1069055Joshua_AnderssonMeetings (IOI18_meetings)C++14
4 / 100
5595 ms2316 KiB
#include "meetings.h"

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll linf = ll(1e18);

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> p2;

#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define repe(i, container) for (auto& i : container)
#define sz(container) ((int)container.size())
#define all(x) begin(x),end(x)

#if _LOCAL
#define assert(x) if (!(x)) __debugbreak()
#endif

typedef vector<ll> vll;

vll minimum_costs(vi H, std::vector<int> l, std::vector<int> r)
{
	vll h(H.begin(), H.end());
	int q = sz(l);
	vll ret(q);
	rep(qu, q)
	{
		ll ans = linf;

		repp(i, l[qu], r[qu] + 1)
		{
			ll cost = h[i];

			ll la = h[i];
			repp(j, i+1, r[qu]+1)
			{
				la = max(la, h[j]);
				cost += la;
			}
			la = h[i];
			for (int j = i-1; j >= l[qu]; j--)
			{
				la = max(la, h[j]);
				cost += la;
			}

			ans = min(ans, cost);
		}

		ret[qu] = ans;
	}
	return ret;
}
#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...