/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 772.0 KiB
#2 Wrong Answer 1ms 332.0 KiB
#3 Wrong Answer 23ms 596.0 KiB
#4 Wrong Answer 30ms 1.531 MiB
#5 Wrong Answer 61ms 3.273 MiB
#6 Wrong Answer 62ms 3.23 MiB
#7 Wrong Answer 38ms 540.0 KiB
#8 Wrong Answer 44ms 820.0 KiB
#9 Wrong Answer 20ms 1.512 MiB
#10 Wrong Answer 24ms 804.0 KiB
#11 Wrong Answer 21ms 1.145 MiB

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-05-22 09:42:56
Judged By
Score
5
Total Time
62ms
Peak Memory
3.273 MiB