# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116051 | LucaIlie | Group Photo (JOI21_ho_t3) | C++17 | 5056 ms | 100700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5000;
int h[MAX_N + 1], p[MAX_N + 1], lower[MAX_N + 1][MAX_N + 1], cost[MAX_N + 1][MAX_N + 1], minCost[MAX_N + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ ) {
cin >> h[i];
p[h[i]] = i;
}
for ( int i = 1; i <= n; i++ ) {
for ( int j = 1; j < i; j++ )
lower[i][h[j]]++;
for ( int j = 1; j <= n; j++ )
lower[i][j] += lower[i][j - 1];
}
for ( int l = 1; l <= n; l++ ) {
for ( int r = l; r <= n; r++ ) {
for ( int i = 1; i <= n; i++ ) {
if ( l <= h[i] && h[i] <= r )
cost[l][r] += lower[i][h[i] - 1] - lower[i][l - 1] + lower[i][n] - lower[i][r];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |