Submission #1034338

# Submission time Handle Problem Language Result Execution time Memory
1034338 2024-07-25T12:29:04 Z vjudge1 cmp (balkan11_cmp) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

string abc = "abcdefghijklmnopqrstuvwxyz";

#define int long long

int m = 1003;

void solve(){
    int n, qq;
    cin >> n >> qq;
    // vector<int> v(n);
    vector<int> a(m, 0);
    int r;
    int sz = 0;
    for(int i = 0; i < n; i++){
        cin >> r;
        if(a[r]==0) sz++;
        a[r]++;
    }
    cin >> qq >> qq;
    vector<int> w, v(sz);
    for(int i = 0; i < m; i++){
        if(a[i] != 0){
            w.push_back(a[i]);
        }
    }
    sort(w.rbegin(), w.rend());
    int st = sz/2;
    v[st]=w[0];
    st--;
    int res = 2;
    for(int i = 1; i < sz; i++){
        v[st]=w[i];
        if(i%2 == 0) st-=res;
        else st+=res;
        res++;
    }

    int ans = 0;
    n = v.size();
    for(int i = 0; i < n; i++){
        ans+=v[i]*(v[i]+1)/2;
    }
    
    queue<int> q;
    int cur = 0;
    res = 0;
    for(int i = 1; i < n; i++){
        cur+=(i+1)*v[i];
        res+=v[i];
        q.push(v[i]);
    }
    for(int i = 0; i < n-1; i++){
        ans+=v[i]*cur;
        int a = q.front();
        cur-=res;
        cur-=a;
        res-=a;
    }

    cout << ans << endl;
    

}


signed main(){
    int t = 1;

    while(t--){
        solve();
    }
}

Compilation message

/usr/bin/ld: /tmp/ccCC9apN.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc98gGBN.o:cmp.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccCC9apN.o: in function `main':
grader.cpp:(.text.startup+0x3b): undefined reference to `remember(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x13c): undefined reference to `compare(int)'
collect2: error: ld returned 1 exit status