Submission #481729

#TimeUsernameProblemLanguageResultExecution timeMemory
481729BackNoobRabbit Carrot (LMIO19_triusis)C++14
100 / 100
26 ms4112 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define endl '\n' #define mask(i) (1LL << (i)) #define ull unsigned long long #define ld long double using namespace std; const int mxN = 3e5 + 227; const ll inf = 1e9 + 277; const int mod = 1e9 + 7; const ll infll = 1e18 + 7; const int base = 307; const int LOG = 20; template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } int a[mxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); //freopen("task.inp" , "r" , stdin); //freopen("task.out" , "w" , stdout); int n , limit; cin >> n >> limit; for(int i = 1 ; i <= n ; i++) cin >> a[i]; vector<int> lis; for(int i = 1 ; i <= n ; i++) { a[i] -= (limit * i); a[i] = -a[i]; if(a[i] < 0) continue; //cout << a[i] << ' '; int pos = upper_bound(lis.begin() , lis.end() , a[i]) - lis.begin(); if(pos == (int) lis.size()) lis.push_back(a[i]); else lis[pos] = a[i]; } cout << n - (int) lis.size(); 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...