#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int Q,N;
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) {
Q = L.size(); N = H.size();
vector<long long> C(Q);
for (int q = 0; q < Q; q++) {
ll minCost = -1;
for (int x = L[q]; x <= R[q]; x++) {
ll cost = 0;
int high = 0;
for (int j = x; j >= L[q]; j--) {
high = max(high,H[j]);
cost += high;
}
high = H[x];
for (int j = x+1; j <= R[q]; j++) {
high = max(high,H[j]);
// cout << high << "\n";
cost += high;
}
// cout << x << " " << cost << "\n";
minCost = (minCost == -1 ? cost : min(cost,minCost));
}
C[q] = minCost;
}
return C;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
348 KB |
Output is correct |
3 |
Correct |
105 ms |
384 KB |
Output is correct |
4 |
Correct |
34 ms |
392 KB |
Output is correct |
5 |
Correct |
105 ms |
384 KB |
Output is correct |
6 |
Correct |
13 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
106 ms |
388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
348 KB |
Output is correct |
3 |
Correct |
105 ms |
384 KB |
Output is correct |
4 |
Correct |
34 ms |
392 KB |
Output is correct |
5 |
Correct |
105 ms |
384 KB |
Output is correct |
6 |
Correct |
13 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
106 ms |
388 KB |
Output is correct |
10 |
Execution timed out |
5527 ms |
476 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Execution timed out |
5509 ms |
1528 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Execution timed out |
5509 ms |
1528 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
348 KB |
Output is correct |
3 |
Correct |
105 ms |
384 KB |
Output is correct |
4 |
Correct |
34 ms |
392 KB |
Output is correct |
5 |
Correct |
105 ms |
384 KB |
Output is correct |
6 |
Correct |
13 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
106 ms |
388 KB |
Output is correct |
10 |
Execution timed out |
5527 ms |
476 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |