/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 492.0 KiB
#2 Wrong Answer 2ms 636.0 KiB
#3 Wrong Answer 57ms 584.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e6+10,MOD=1000000007;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
       int n,k;
       cin>>n>>k;
       priority_queue<int>pq;
       map<int,int>mp;
       for(int i=1;i<=n;i++){
         int a;
         cin>>a;
         mp[a]++;
       }
       for(auto it:mp){
        pq.push(it.second);
       }
       vector<int>vis(n+1,0);
       int ans=0;
       for(int i=1;i<=n-k+1;i++){
        if(vis[i])continue;
        int cnt=n/k;
        for(int j=i;j<=n;j+=k){
            vis[j]=1;
            //cnt++;
        }
        int x=pq.top();
        pq.pop();
        int laga=min(x,cnt);
        ans+=(cnt-laga);
        x-=laga;
        if(x>0)pq.push(x);

       }
       cout<<ans<<"\n";

    }
    
   
   return 0;
}
 

Information

Submit By
Type
Submission
Problem
P1062 Roy and Array
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-22 09:42:56
Judged At
2024-11-11 03:29:53
Judged By
Score
5
Total Time
57ms
Peak Memory
636.0 KiB