Submission #895123

# Submission time Handle Problem Language Result Execution time Memory
895123 2023-12-29T12:56:45 Z d4xn Rabbit Carrot (LMIO19_triusis) C++17
14 / 100
1000 ms 15640 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5+1, inf = INT_MAX;

int n, m, a[N];
vector<int> suf, dp[2];

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> m;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  dp[0].clear();
  dp[0].resize(1);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    suf.clear();
    suf.resize(m*(i-1) + 1);
    suf[m*(i-1)] = dp[(i-1)%2][m*(i-1)];
    for (int j = m*(i-1) - 1; j >= 0; j--) {
      suf[j] = min(dp[(i-1)%2][j], suf[j+1]);
    }

    dp[i%2].clear();
    dp[i%2].resize(m*i + 1);
    for (int j = 0; j <= m*i; j++) {
      dp[i%2][j] = suf[max(0, j-m)] + (j != a[i]);
    }
  }

  int ans = inf;
  for (int i = 0; i <= n*m; i++) {
    ans = min(ans, dp[n%2][i]);
  }
  cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 1380 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 1380 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 72 ms 1116 KB Output is correct
21 Correct 571 ms 1904 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Execution timed out 1093 ms 15640 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 72 ms 1116 KB Output is correct
5 Correct 571 ms 1904 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Execution timed out 1093 ms 15640 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 72 ms 1116 KB Output is correct
5 Correct 571 ms 1904 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Execution timed out 1093 ms 15640 KB Time limit exceeded
8 Halted 0 ms 0 KB -