# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
270934 | 2020-08-18T04:13:23 Z | leductoan | Studentsko (COCI14_studentsko) | C++14 | 47 ms | 516 KB |
#include<bits/stdc++.h> using namespace std; #define task "" #define BIT(x, i) (((x) >> (i)) & 1) #define lb lower_bound #define ub upper_bound #define lla(v) (v).begin(),(v).end() #define zs(v) (v).size() #define fi first #define se second #define pb push_back typedef long double ld; typedef long long ll; typedef pair<int,int> pii; const int mod=1000000007; /// 998244353 const int base=311; const int N=1e5+5; pii a[5005]; int n,k,b[5005],dp[5005]; void solved() { cin>>n>>k; for(int i=0;i<n;++i) cin>>a[i].fi,a[i].se=i; sort(a,a+n); for(int i=0;i<n;++i) b[a[i].se]=i/k; int ans=0; for(int i=0;i<n;++i) { dp[i]=1; for(int j=0;j<i;++j) if(b[j]<=b[i]) dp[i]=max(dp[i],dp[j]+1); ans=max(ans,dp[i]); } cout<<n-ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } solved(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 504 KB | Output is correct |
2 | Correct | 38 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 512 KB | Output is correct |
2 | Correct | 47 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 512 KB | Output is correct |
2 | Correct | 27 ms | 516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 464 KB | Output is correct |
2 | Correct | 44 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 512 KB | Output is correct |
2 | Correct | 44 ms | 416 KB | Output is correct |