Submission #620801

# Submission time Handle Problem Language Result Execution time Memory
620801 2022-08-03T09:25:14 Z berr Newspapers (CEOI21_newspapers) C++17
0 / 100
6 ms 5204 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    vector<int> a(300005, 0);
    int n, q; cin>>n>>q;

    for(int i=0; i<n; i++)
    {
        int x; cin>>x;
        a[x]++;
    }

    sort(a.begin(), a.end());
    int ans=0;
    vector<int> b, c;
    for(int i=0; i<a.size(); i++)
    {
        if(a[i]>0)
        {
            if(i%2) b.push_back(a[i]);
            else c.push_back(a[i]);
        }
    }
    int l, r; cin>>l>>r;


    reverse(c.begin(), c.end());
    for(auto i: c) b.push_back(i);

    int sum=0, all=0;
    for(int i=0; i<b.size(); i++)
    {
        sum+=all;
        ans+=sum*b[i]+(b[i]*(b[i]+1))/2;
        all+=b[i];
        sum+=b[i];
    }

    cout<<ans;
}

Compilation message

newspapers.cpp: In function 'int32_t main()':
newspapers.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0; i<a.size(); i++)
      |                  ~^~~~~~~~~
newspapers.cpp:36:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0; i<b.size(); i++)
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5176 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5204 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5176 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -