| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 388505 | LucaDantas | Group Photo (JOI21_ho_t3) | C++17 | 481 ms | 67408 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 5e3+10;
bool mark[maxn];
int a[maxn], val[maxn][maxn], dp[maxn];
int main() {
int n; scanf("%d", &n);
int inv = 0;
for(int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
for(int j = a[i]+1; j <= n; j++) {
inv += mark[j];
val[a[i]][j] += mark[j];
}
for(int j = a[i]-1; j >= 1; j--)
val[j][a[i]] -= mark[j];
mark[a[i]] = 1;
}
for(int sz = 2; sz <= n; sz++) {
for(int i = 1; i+sz <= n; i++) {
int j = i + sz;
val[i][j] += val[i][j-1] + val[i+1][j] - val[i+1][j-1];
}
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= i; j++)
dp[i] = max(dp[i], val[j][i] + dp[j-1]);
printf("%d\n", inv - dp[n]);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
