Submission #969003

#TimeUsernameProblemLanguageResultExecution timeMemory
969003dostsRabbit Carrot (LMIO19_triusis)C++17
0 / 100
0 ms348 KiB
//Dost SEFEROĞLU #pragma GCC optimize("O3,unroll-loops,Ofast") #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define vi vector<int> const int N = 5e2+1,inf = 2e18,MOD = 1e9+7; void solve() { int n,m; cin >> n >> m; vi a(n+1); for (int i=1;i<=n;i++) cin >> a[i]; vi dp(n+1,inf); dp[0] = 0; for (int i=1;i<=n;i++) { dp[i] = a[i] <= m ? 1 : -inf; for (int j = i;j>=1;j--) { if (abs(a[i]-a[j]) <= m) dp[i] = max(dp[i],dp[j]+1); } } cout << n-max(0ll,dp[n]) << '\n'; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...