Submission #1123311

#TimeUsernameProblemLanguageResultExecution timeMemory
1123311ezzzayRabbit Carrot (LMIO19_triusis)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=5005; int dp[N]; int tmp[N]; int a[N]; signed main(){ for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ dp[i][j]=1e9; } } int n,k; cin>>n>>k; for(int i=1;i<=n;i++)cin>>a[i]; dp[0]=0; int ans=n; for(int i=1;i<=n;i++){ for(int hi=0;hi<=1000;hi++){ for(int hj=0;hj<=1000;hj++){ if(hi-hj>k)continue; if(hi!=a[i]){ dp[hi]=min(dp[hi],tmp[hj]+1); if(i==n)ans=min(ans,dp[hi]); } else{ dp[hi]=min(dp[hi],tmp[hj]); if(i==n)ans=min(ans,dp[hi]); } } } for(int i=1;i<=1000;i++)tmp[i]=dp[i]; } cout<<ans; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:14:18: error: invalid types 'long long int[long long int]' for array subscript
   14 |             dp[i][j]=1e9;
      |                  ^