# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88787 | 2018-12-08T18:11:33 Z | asifthegreat | Studentsko (COCI14_studentsko) | C++14 | 57 ms | 964 KB |
#include <bits/stdc++.h> using namespace std; const int N = 50003; int ara[N],tmp[N],dp[N]; vector<int>v; int n,k; map<int,int>id; int main() { scanf("%d %d",&n,&k); for(int i = 0; i < n;i++){ scanf("%d",&ara[i]); tmp[i] = ara[i]; } sort(tmp,tmp+n); for(int i = 0; i < n;i++){ id[tmp[i]] = i/k; } for(int i = 0; i < n;i++){ v.push_back(id[ara[i]]); } //for(auto i: v){ // cout << i << " "; // }cout << endl; for(int i = 0; i <= n;i++)dp[i] = 1; for(int i = 1; i < n;i++){ for(int j = 0; j < i;j++){ if(v[j] <= v[i])dp[i] = max(dp[i],dp[j]+1); } } cout << n-*max_element(dp,dp+n) << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 440 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 544 KB | Output is correct |
2 | Correct | 2 ms | 672 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 836 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 940 KB | Output is correct |
2 | Correct | 46 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 940 KB | Output is correct |
2 | Correct | 56 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 940 KB | Output is correct |
2 | Correct | 40 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 940 KB | Output is correct |
2 | Correct | 53 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 940 KB | Output is correct |
2 | Correct | 55 ms | 964 KB | Output is correct |