#include "meetings.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,j,ma[5050][5050],kan[5050][5050],kir[5050][5050],has;
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
std::vector<int> R) {
n=H.size();
for(i=0;i<n;i++)
{
ma[i][i]=H[i];
for(j=i+1;j<n;j++)
ma[i][j]=max(ma[i][j-1],(ll)H[j]);
}
for(i=0;i<n;i++)
{
kan[i][i]=H[i];
for(j=i+1;j<n;j++)
kan[i][j]=kan[i][j-1]+ma[i][j];
}
for(i=0;i<n;i++)
{
kir[i][i]=H[i];
for(j=i-1;j>=0;j--)
kir[i][j]=kir[i][j+1]+ma[j][i];
}
/*for(i=0;i<n;i++)
for(j=i;j<n;j++)
{
cout<<i<<" "<<j<<" "<<kir[j][i]<<" "<<kan[i][j]<<" "<<ma[i][j]<<"\n";
}*/
int Q = L.size();
std::vector<long long> C(Q);
for (int TC = 0; TC < Q; ++TC)
{
has=kir[R[TC]][L[TC]];
for(i=L[TC];i<R[TC];i++)
has=min(has,kir[i][L[TC]]+kan[i+1][R[TC]]);
C[TC]=has;
}
return C;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
165 ms |
142428 KB |
Output is correct |
3 |
Correct |
166 ms |
142516 KB |
Output is correct |
4 |
Correct |
172 ms |
142464 KB |
Output is correct |
5 |
Correct |
167 ms |
142396 KB |
Output is correct |
6 |
Correct |
165 ms |
142508 KB |
Output is correct |
7 |
Correct |
167 ms |
142396 KB |
Output is correct |
8 |
Correct |
174 ms |
142456 KB |
Output is correct |
9 |
Correct |
166 ms |
142416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
165 ms |
142428 KB |
Output is correct |
3 |
Correct |
166 ms |
142516 KB |
Output is correct |
4 |
Correct |
172 ms |
142464 KB |
Output is correct |
5 |
Correct |
167 ms |
142396 KB |
Output is correct |
6 |
Correct |
165 ms |
142508 KB |
Output is correct |
7 |
Correct |
167 ms |
142396 KB |
Output is correct |
8 |
Correct |
174 ms |
142456 KB |
Output is correct |
9 |
Correct |
166 ms |
142416 KB |
Output is correct |
10 |
Correct |
759 ms |
352220 KB |
Output is correct |
11 |
Correct |
1291 ms |
352156 KB |
Output is correct |
12 |
Correct |
751 ms |
352176 KB |
Output is correct |
13 |
Correct |
1283 ms |
352176 KB |
Output is correct |
14 |
Correct |
755 ms |
352196 KB |
Output is correct |
15 |
Correct |
756 ms |
352128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
372 KB |
Output is correct |
2 |
Runtime error |
362 ms |
308300 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
372 KB |
Output is correct |
2 |
Runtime error |
362 ms |
308300 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
165 ms |
142428 KB |
Output is correct |
3 |
Correct |
166 ms |
142516 KB |
Output is correct |
4 |
Correct |
172 ms |
142464 KB |
Output is correct |
5 |
Correct |
167 ms |
142396 KB |
Output is correct |
6 |
Correct |
165 ms |
142508 KB |
Output is correct |
7 |
Correct |
167 ms |
142396 KB |
Output is correct |
8 |
Correct |
174 ms |
142456 KB |
Output is correct |
9 |
Correct |
166 ms |
142416 KB |
Output is correct |
10 |
Correct |
759 ms |
352220 KB |
Output is correct |
11 |
Correct |
1291 ms |
352156 KB |
Output is correct |
12 |
Correct |
751 ms |
352176 KB |
Output is correct |
13 |
Correct |
1283 ms |
352176 KB |
Output is correct |
14 |
Correct |
755 ms |
352196 KB |
Output is correct |
15 |
Correct |
756 ms |
352128 KB |
Output is correct |
16 |
Correct |
2 ms |
372 KB |
Output is correct |
17 |
Runtime error |
362 ms |
308300 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |