# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
397694 | 2021-05-02T21:21:29 Z | ChrisT | Group Photo (JOI21_ho_t3) | C++17 | 1 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 5e3 + 5; int dp[MN], f[MN][MN], a[MN], stopAt[MN]; int main () { int n; scanf ("%d",&n); for (int i = 1; i <= n; i++) scanf ("%d",&a[i]); for (int i = 1; i <= n; i++) { for (int j = i+1; j <= n; j++) { if (a[i] < a[j]) { f[1][a[j]]++; f[a[i]+1][a[j]]--; } else { f[a[j]+1][1]++; f[a[i]+1][1]--; } } } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) f[i][j] += f[i-1][j] + f[i][j-1] - f[i-1][j-1]; for (int i = 1; i <= n; i++) { dp[i] = 1e9; for (int j = i; j >= 1; j--) dp[i] = min(dp[i],dp[j-1]+f[j][i]); } printf ("%d\n",dp[n]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Incorrect | 1 ms | 332 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Incorrect | 1 ms | 332 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Incorrect | 1 ms | 332 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Incorrect | 1 ms | 332 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Incorrect | 1 ms | 332 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |