답안 #89381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89381 2018-12-12T18:27:33 Z alipasha 학생 (COCI14_studentsko) C++14
10 / 100
7 ms 2856 KB
#include<bits/stdc++.h>

using namespace std;

int test;
int n;
int k;
int dp[1005][2];
int ps[1005][1005];
int f[1005][2];
int A[1005];
pair<int,int> B[1005];
int main(){
    cin >> n;
    cin >> k;
    memset(f,-1,sizeof f);
    for(int i=0; i<n; i++)
    {
        int v;
        cin >> v;
        B[i]={v,i};
    }
    sort(B,B+n);
    int group=0;
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        A[B[i].second]=group;
        cnt++;
        if(cnt==k)
        {
            cnt=0;
            group++;
        }
    }
    ps[0][A[0]]++;
    f[A[0]][0]=0;
    f[A[0]][1]=0;
    for(int i=1; i<n; i++)
    {
        for(int j=0; j<n/k; j++)
        {
            ps[i][j]=ps[i-1][j];
        }
        ps[i][A[i]]++;
        if(f[A[i]][0]==-1)
        {
            f[A[i]][0]=i;
            f[A[i]][1]=i;
        }
        else
        {
            f[A[i]][1]=i;
        }
    }
    int ans=0;
    for(int i=0; i<n/k; i++)
    {
        int start=f[i+1][0];//avalin i+1;
        int end=f[i][1];// akharin i;
        //ps[end][i]= bad az avalin i+1 chand i oomade
        //ps[n][i]-ps[start][i]
        ans+=min(ps[end][i+1],ps[n-1][i]-ps[start][i]);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 556 KB Output is correct
2 Incorrect 2 ms 600 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1432 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1432 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1432 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 2776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 2856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 2856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 2856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -