Submission #40621

# Submission time Handle Problem Language Result Execution time Memory
40621 2018-02-05T21:36:37 Z repeating Studentsko (COCI14_studentsko) C++11
10 / 100
18 ms 1060 KB
#include <bits/stdc++.h>

#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9+1;
const long long MOD = 1e9+7;
const int MX=200015;
int a[5005];
vector<pii> v;
bool vis[5005];
int start[5005];
int FIND(int n,int y){
    int res=0;
    for(int i=0;i<n;i++)
        res+=(y==a[i]);
    R res;
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        v.pb({a[i],i});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        a[v[i].S]=i/m;
    }
    for(int i=0;i<n;i++){
        if(vis[i])continue;
        int num=a[i],tk=0;
        for(int j=i;j<n;j++){
            if(a[j]==num){
                vis[j]=1;
                tk++;
                start[i]++;
                if(tk==m)tk=0,num++;
            }
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        res=max(res,start[i]+FIND(i,a[i]-1));
    }
    cout<<n-res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 568 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 780 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1060 KB Output isn't correct
2 Halted 0 ms 0 KB -