Submission #140629

#TimeUsernameProblemLanguageResultExecution timeMemory
140629Rouge_HugoStudentsko (COCI14_studentsko)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n,k; int a[5005]; int tree[5005*3]; void update (int ind,int st,int end,int uind,int uval) { if (st==end) { tree[ind]=uval; return ; } int m=(st+end)/2; if (uind>m)update (ind*2+2,m+1,end,uind,uval); else update(ind*2+1,st,m,uind,uval); tree[ind]=max(tree[ind*2+1],tree[ind*2+2]); } query(int ind,int st,int end,int uind) { if (end<=uind)return tree[ind]; int m=(st+end)/2; if (uind>m)return max(query(ind*2+1,st,m,uind),query (ind*2+2,m+1,end,uind)); else return query (ind*2+1,st,m,uind); } map<int,int>m; int main() { cin>>n>>k; for(int i=0;i<n;i++){ cin>>a[i]; m[a[i]]++; } int r=0,re=0; for(auto it:m) { re++; re%=k; m[it.first]=r; if (re==0)r++; }int mx=0; k=n/k; r=0; for(int i=0;i<n;i+=1) { r=query(0,0,k-1,m[a[i]]); // cout<<m[a[i]]<<" "; mx=max(mx,r+1); update (0,0,k-1,m[a[i]],r+1); } cout<<n-mx; return 0; }

Compilation message (stderr)

studentsko.cpp:19:38: error: ISO C++ forbids declaration of 'query' with no type [-fpermissive]
 query(int ind,int st,int end,int uind)
                                      ^