Submission #797273

# Submission time Handle Problem Language Result Execution time Memory
797273 2023-07-29T08:42:33 Z devariaota Rabbit Carrot (LMIO19_triusis) C++17
35 / 100
118 ms 196372 KB
#include <bits/stdc++.h>
#define inf INT_MAX
#define longlonginf LONG_LONG_MAX
#define mod  1000000007
#define MAXN 100005
#define ll long long
#define deb(x) cerr<<"[ "<<#x<<" = "<<x<<" ]";
#define yes() cout<<"YES\n";
#define no() cout<<"NO\n";
using namespace std;

ll n,m,k,q,x;
ll h;
ll ans = 0;
string subtask;

void solve(){
  cin>>n>>m;
  ll dp[n+1][5005];
  ll a[n+1];
  for(int i = 1 ; i <= n ; i++){
    cin>>a[i];
  }
  for(int i = 0 ; i <= 5000 ; i++){
    if( a[n] != i ) dp[n][i] = 1;
    else dp[n][i] = 0;
  }
  ll mn;
  for(int i = n-1 ; i > 0 ; i--){
    mn = longlonginf;
    for(int j = 0 ; j <= m ; j++){
      mn = min(mn,dp[i+1][j]);
    }
    for(int j = 0 ; j <= 5000 ; j++){
      if( j+m <= 5000 ) mn = min(mn,dp[i+1][j+m]);
      dp[i][j] = mn + (a[i] != j);
    }
  }
  ans = longlonginf;
  for(int i = 0 ; i <= m ; i++){
    ans = min(ans,dp[1][i]);
  }
  cout<<ans<<"\n";
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  //cin>>T;
  for(int i = 0 ; i < T ; i++){
    //cout<<"Case #"<<i+1<<": ";
    solve();
  }
  return 0;
}

/*
  not i but x
  logical operator
  wrong example/proof
  thoroughly
  wrong variables
  thinking it wrong
  bruh just try some test case
  capitals ;-;
  wrong data structure lol
  count memory usement
  corner case
  oversized array
  orders
  statements
  size initializer
  while con
  map -> array
  wrong digits??
  swapped variables??
  check if theres any variabled
  that got declared twice
  find some pattern
  name collision
  constraints??!
  mod !!
  resets
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 724 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 724 KB Output is correct
15 Correct 1 ms 724 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 724 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 724 KB Output is correct
15 Correct 1 ms 724 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 82 ms 159024 KB Output is correct
21 Correct 102 ms 196264 KB Output is correct
22 Correct 100 ms 196136 KB Output is correct
23 Correct 115 ms 196240 KB Output is correct
24 Correct 116 ms 196144 KB Output is correct
25 Correct 95 ms 196168 KB Output is correct
26 Correct 107 ms 196372 KB Output is correct
27 Correct 97 ms 196168 KB Output is correct
28 Correct 95 ms 196172 KB Output is correct
29 Correct 96 ms 196260 KB Output is correct
30 Correct 96 ms 196212 KB Output is correct
31 Correct 103 ms 196300 KB Output is correct
32 Correct 104 ms 196192 KB Output is correct
33 Correct 104 ms 196156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 82 ms 159024 KB Output is correct
5 Correct 102 ms 196264 KB Output is correct
6 Correct 100 ms 196136 KB Output is correct
7 Correct 115 ms 196240 KB Output is correct
8 Correct 116 ms 196144 KB Output is correct
9 Correct 95 ms 196168 KB Output is correct
10 Correct 107 ms 196372 KB Output is correct
11 Correct 97 ms 196168 KB Output is correct
12 Correct 95 ms 196172 KB Output is correct
13 Correct 96 ms 196260 KB Output is correct
14 Correct 96 ms 196212 KB Output is correct
15 Correct 103 ms 196300 KB Output is correct
16 Correct 104 ms 196192 KB Output is correct
17 Correct 104 ms 196156 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 94 ms 196260 KB Output is correct
35 Incorrect 118 ms 196176 KB Output isn't correct
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 94 ms 196260 KB Output is correct
2 Incorrect 118 ms 196176 KB Output isn't correct
3 Halted 0 ms 0 KB -