Submission #593838

# Submission time Handle Problem Language Result Execution time Memory
593838 2022-07-11T16:15:43 Z vladislav11 Diversity (CEOI21_diversity) C++14
0 / 100
2 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int n, q, l, r;
vector<int> a;

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

    cin >> n >> q;

    a.resize(n);
    for ( auto& el : a )
        cin >> el;

    cin >> l >> r;

    sort( a.begin(), a.end() );

    vector< pair<int,int> > b;
    b.push_back({ 1, a[0] });

    for ( int i=1; i<n; i++ )
    {
        if ( a[i] == b.back().second )
            b.back().first++;
        else
            b.push_back({ 1, a[i] });
    }

    sort( b.begin(), b.end(), greater< pair<int,int> >() );

    vector<int> c;

    while ( b.size() )
    {
        for ( int i=0; i<b.size(); i++ )
        {
            c.push_back( b[i].second );
            b[i].first--;
        }

        while ( b.size() && b.back().first == 0 )
            b.pop_back();
    }

    /*for ( auto& el : c )
        cout << el << ' ';
    cout << '\n';*/

    ll ans = 0;

    for ( int i=0; i<n; i++ )
    for ( int j=i; j<n; j++ )
        ans += set<int>( c.begin()+i, c.begin()+j+1 ).size();

    cout << ans;

    return 0;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for ( int i=0; i<b.size(); i++ )
      |                        ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -