Submission #1013631

#TimeUsernameProblemLanguageResultExecution timeMemory
1013631vjudge1Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
41 ms4960 KiB
// 23 - 12 - 23 #include<bits/stdc++.h> using namespace std; #define read() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define day() time_t now = time(0);char* x = ctime(&now);cerr<<"Right Now Is : "<<x<<"\n" #define ii pair<int,int> #define X first #define Y second const long long MAX = (int)2e5 + 5; const long long INF = (int)1e9; const long long MOD = (int)1e9 + 7; int bit[MAX]; int a[MAX]; int n,m; void update(int id,int val){ for(;id < MAX;id += id & -id)bit[id] = max(bit[id],val); } int get(int id){ int res = 0; for(;id > 0;id -= id & -id)res = max(res,bit[id]); return res; } signed main(){ read(); cin >> n >> m; vector<int> rt; vector<int> f; for(int i = 1;i <= n;i++){ cin >> a[i]; if(i * m >= a[i]){ rt.push_back(i * m - a[i]); f.push_back(i * m - a[i]); } } sort(rt.begin(),rt.end()); rt.erase(unique(rt.begin(),rt.end()),rt.end()); int res = 0; for(auto v : f){ int u = get(lower_bound(rt.begin(),rt.end(),v) - rt.begin() + 1) + 1; update(lower_bound(rt.begin(),rt.end(),v) - rt.begin() + 1,u); res = max(res,u); } cout << n - res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...