Submission #885896

#TimeUsernameProblemLanguageResultExecution timeMemory
885896ByeWorldStudentsko (COCI14_studentsko)C++14
100 / 100
5 ms2652 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") #define bupol __builtin_popcount #define int long long #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) using namespace std; const int MAXN = 3e5+20; const int LOG = 60; const int MOD = 998244353; const int SQRT = 520; const int INF = 1e18; typedef pair<int,int> pii; typedef pair<pii,int> ipii; int n, k; int a[MAXN]; struct seg { int st[4*MAXN]; int que(int id, int l, int r, int x, int y){ if(x<=l && r<=y) return st[id]; if(r<x || y<l) return -INF; return max(que(lf, l, md, x, y), que(rg, md+1, r, x, y)); } int upd(int id, int l, int r, int x, int y){ if(x<=l && r<=x) return st[id] = y; if(r<x || x<l) return st[id]; return st[id] = max(upd(lf, l, md, x, y), upd(rg, md+1, r, x, y)); } } A; signed main(){ //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); vector <int> vec; cin >> n >> k; for(int i=1; i<=n; i++){ cin >> a[i]; vec.pb(a[i]); } sort(vec.begin(), vec.end()); for(int i=1; i<=n; i++){ a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin(); a[i] /= k; a[i]++; } for(int i=1; i<=n; i++){ int qu = A.que(1, 1, n, 1, a[i]); A.upd(1, 1, n, a[i], qu+1); } cout << n-A.que(1, 1, n, 1, n) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...