Submission #89382

#TimeUsernameProblemLanguageResultExecution timeMemory
89382alipashaStudentsko (COCI14_studentsko)C++14
10 / 100
7 ms2612 KiB
#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-1; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...