Submission #578693

#TimeUsernameProblemLanguageResultExecution timeMemory
578693shubham20_03Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
34 ms7488 KiB
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); #define deb(x) cout<<#x<<'='<<x<<'\n'; #define deb2(x,y) cout<<#x<<'='<<x<<", "<<#y<<'='<<y<<'\n'; #define int long long #define all(x) (x).begin(), (x).end() #define pii pair<int, int> #define pb push_back #define f first #define s second #define sz(x) (int)(x).size() const long double PI = acos(-1); const int mod = 1e9 + 7, inf = 1e18; const int D = 2e5 + 10; // UG - internal editorial signed main() { fastio //freopen("../input1.txt", "r", stdin); //freopen("../output1.txt", "w", stdout); int n, m; cin >> n >> m; int a[n + 5] = {0}; for (int i = 1; i <= n; i++) cin >> a[i]; int b[n + 5] = {0}; for (int i = 1; i <= n; i++) b[i] = m * i - a[i]; vector<int> v; for (int i = 1; i <= n; i++) { if (b[i] < 0) continue; auto p = upper_bound(all(v), b[i]) - v.begin(); if (p == sz(v)) v.pb(b[i]); else v[p] = b[i]; } cout << n - sz(v) << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...