# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40627 | 2018-02-06T00:46:19 Z | Hassoony | Studentsko (COCI14_studentsko) | C++14 | 7 ms | 832 KB |
#include<bits/stdc++.h> #include<unordered_map> using namespace std; typedef unsigned long long ll; typedef double D; const ll inf=(1ll<<61); const ll mod=1e9+7; const int MX=5009; int n,k,a[MX],dp[MX]; int bn(int l,int r,int x){ int ans=0; while(l<=r){ int mid=(l+r)/2; if(dp[mid]<x)r=mid-1; else l=mid+1; } return l; } int DP(){ int ans=1; dp[0]=a[0]; for(int i=1;i<n;i++){ if(a[i]<dp[0])dp[0]=a[i]; else if(a[i]>=dp[ans-1])dp[ans++]=a[i]; else dp[bn(0,ans,a[i])]=a[i]; } return ans; } map<int,int>hashy; int main(){ cin>>n>>k; for(int i=0;i<n;i++){ cin>>a[i]; hashy[a[i]]=1; } int tt=1,j=1; for(auto pp:hashy){ hashy[pp.first]=tt; if(j%k==0)++tt; j++; } for(int i=0;i<n;i++)a[i]=hashy[a[i]]; cout<<n-DP()<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 352 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 552 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 732 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 784 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 784 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 784 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 832 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |