/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 1ms 320.0 KiB
#3 Accepted 40ms 572.0 KiB
#4 Wrong Answer 66ms 2.434 MiB
#5 Wrong Answer 121ms 3.988 MiB
#6 Accepted 112ms 3.844 MiB
#7 Wrong Answer 82ms 612.0 KiB
#8 Wrong Answer 90ms 1.039 MiB
#9 Wrong Answer 39ms 2.465 MiB
#10 Accepted 48ms 576.0 KiB
#11 Wrong Answer 29ms 568.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ps(b) cout << (b ? "YES" : "NO") << '\n'
#define pc cout << "Case " << tc << ": "
#ifdef LOCAL
#include "def.h"
#else
#define ck(...) 
#endif
const ll M = 1e9 + 7, N = 2e5 + 5;

void test(int tc) {
    ll a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, m = 0, n = 0, q = 0;
    cin >> n >> k;
    map<ll, ll> mp;
    for (i = 0; i < n; ++i) { cin >> a;
        mp[a]++;
    }
    multiset<ll, greater<>> st;
    for(auto [f,s] : mp)
        st.insert(s);
    ck(st);
    a = *st.begin();
    st.erase(st.begin());
    for (i = 0; i < k; ++i){
        // if((!st.empty() and a >= *st.begin()) or (st.empty() and a)) {
        for (j = i; j < n and a > 0; j += k){
            c++;
            a--;
        }
        // }
        ck(i, c, a);
        if (!st.empty() and a < *st.begin()) {
            a = *st.begin();
            st.erase(st.begin());
        }
        // else if(st.empty() and !a)
        //     break;
    }
    cout << n - c;
    cout << '\n';

        // multimap<int, int, greater<>> mmp;  // descending order
        // for(auto &[f, s]:mp) mmp.emplace(s, f);
        // a = 0;
        // while(n){
        //     if(a==0) a = k;
        //     for(auto [f,s]:mmp){
        //         if(mp[s]==0) {
        //             c++;
        //         }
        //         else{
        //             mp[s]--;
        //         }
        //         --n;
        //         if(--a == 0 or !n)
        //             break;
        //     }
        // }
}

signed main() {
    cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit|cin.badbit);
    int tc = 0, t = 1;
    cin >> t;
    while (tc < t) test(++tc);
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1062 Roy and Array
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 18:46:42
Judged At
2024-10-03 13:35:01
Judged By
Score
35
Total Time
121ms
Peak Memory
3.988 MiB