This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 5001;
int n, k;
int a[MAXN];
vector <pii> v;
vector <int> najmanji;
int main(){
cin >> n >> k;
for (int i = 0; i < n; i++){
cin >> a[i];
v.pb(mp(a[i], i));
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++)
a[v[i].se] = (i/k)+1;
najmanji.pb(-inf);
for (int i = 0; i < n; i++){
vector<int>::iterator it = upper_bound(najmanji.begin(), najmanji.end(), a[i]);
if (it == najmanji.end()) najmanji.pb(a[i]);
else *it = a[i];
}
cout << n - najmanji.size() + 1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |