Submission #396992

#TimeUsernameProblemLanguageResultExecution timeMemory
396992mewnianStudentsko (COCI14_studentsko)C++14
100 / 100
3 ms464 KiB
#include <bits/stdc++.h> #define sze(x) (ll)x.size() #define idx(x, a) get<x>(a) #define pb push_back #define fi first #define se second using namespace std; typedef long long ll; const ll MAXN = 5e3 + 3; const ll INF = 1e18 + 7; ll a[MAXN], n, k, b[MAXN], res, lis[MAXN]; int main() { ios_base::sync_with_stdio(0); cout.tie(0); #ifdef OFFLINE freopen("input.inp", "r", stdin); #endif cin >> n >> k; for (ll i = 1; i <= n; ++i) { cin >> a[i]; b[i] = a[i]; } sort(b + 1, b + n + 1); a[0] = -INF; for (ll i = 1; i <= n; ++i) a[i] = (lower_bound(b + 1, b + n + 1, a[i]) - b - 1) / k; fill(lis, lis + n + 1, INF); lis[0] = -INF; for (ll i = 1; i <= n; ++i) { ll r = upper_bound(lis, lis + n + 1, a[i]) - lis; res = max(res, r); lis[r] = a[i]; } 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...
#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...