Submission #797273

#TimeUsernameProblemLanguageResultExecution timeMemory
797273devariaotaRabbit Carrot (LMIO19_triusis)C++17
35 / 100
118 ms196372 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...