Submission #588433

# Submission time Handle Problem Language Result Execution time Memory
588433 2022-07-03T09:28:51 Z jasmin Diversity (CEOI21_diversity) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int n, q;
    cin >> n >> q;
    vector<int> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    map<int,int> cnt;
    for(int i=0; i<n; i++){
        cnt[s[i]]++;
    }
    for(int i=0; i<q; i++){
        int a, b;
        cin >> a >> b;
    }

    vector<pair<int,int> > res(cnt.size());
    int l=0; int r=cnt.size()-1; bool left=true;
    for(auto e: cnt){
        int x=e.first; int anz=e.second;
        if(left){
            res[l]={x, anz};
            l++;
            left=false;
        }
        else{
            res[r]={x, anz};
            r--;
            left=true;
        }
    }

    vector<int> neu(n);
    int i=0;
    for(auto e: cnt){
        int x=e.first;
        int anz=e.second;
        for(int j=0; j<anz; j++, i++){
            neu[i]=x;
        }
    }

    int ans=1;
    int last=1;
    for(int i=1; i<n; i++){
        if(neu[i]==neu[i-1]){
            ans+=last+1;
            last++;
        }
        else{
            ans+=last+i+1;
            last=last+i+1;
        }
    }
    
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -