#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
10 ms |
348 KB |
Output is correct |
3 |
Correct |
60 ms |
448 KB |
Output is correct |
4 |
Correct |
30 ms |
348 KB |
Output is correct |
5 |
Correct |
60 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
62 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
10 ms |
348 KB |
Output is correct |
3 |
Correct |
60 ms |
448 KB |
Output is correct |
4 |
Correct |
30 ms |
348 KB |
Output is correct |
5 |
Correct |
60 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
62 ms |
468 KB |
Output is correct |
10 |
Execution timed out |
5595 ms |
600 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
5589 ms |
2316 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
5589 ms |
2316 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
10 ms |
348 KB |
Output is correct |
3 |
Correct |
60 ms |
448 KB |
Output is correct |
4 |
Correct |
30 ms |
348 KB |
Output is correct |
5 |
Correct |
60 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
62 ms |
468 KB |
Output is correct |
10 |
Execution timed out |
5595 ms |
600 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |