# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88775 | tushar_2658 | Studentsko (COCI14_studentsko) | C++14 | 1075 ms | 972 KiB |
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"
using namespace std;
typedef long long ll;
#define file freopen("in.txt", "r", stdin);
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(), v.end()
#define keepunique(v) (v).erase(unique(all(v)),v.end())
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);
const int maxn = 5005;
int n, k, cnt = 0;
ll arr[maxn];
map<ll, ll>mark;
vector<ll> vec;
int dp[maxn];
int call(int u){
int ans = 0;
if(dp[u] != -1)return dp[u];
for(int i=u+1; i<n; i++){
if(mark[arr[i]] >= mark[arr[u]]){
if(call(i) >= ans)ans = call(i);
}
}
return dp[u] = 1+ans;
}
int solve(){
int lon = 0;
for(int i=0; i<n; i++){
memset(dp, -1, sizeof dp);
lon = max(lon, call(i));
}
return n - lon;
}
int main(){
//file
//fastread
scanf("%d%d", &n, &k);
for(int i=0; i<n; i++){
scanf("%lld", &arr[i]);
vec.pb(arr[i]);
}
//vec1 = vec;
sort(all(vec));
for(int i=0; i<n; i++){
if(i%k == 0)++cnt;
mark[vec[i]] = cnt;
}
printf("%d", solve());
}
Compilation message (stderr)
# | 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... |