Submission #977723

# Submission time Handle Problem Language Result Execution time Memory
977723 2024-05-08T10:03:36 Z Circling Diversity (CEOI21_diversity) C++17
4 / 100
6094 ms 500 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int main(){
    int64_t n, q, a, answer = 1ll << 62, currsum, currans, fact[12];
    map<int, int64_t> cnt;
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> a;
        cnt[a]++;
    }
    vector<int64_t> nums, currorder;
    for (pair<int, int64_t> p: cnt) nums.push_back(p.second);
    fact[0] = 1;
    for (int i = 1; i < 12; i++) fact[i] = i * fact[i - 1];
    for (int i = 0; i < fact[nums.size()]; i++){
        currorder.clear();
        for (int j: nums) currorder.push_back(j);
        for (int j = 0; j < nums.size() - 1; j++) swap(currorder[j], currorder[j + (i / fact[nums.size() - j - 1]) % (nums.size() - j)]);
        currans = 0;
        currsum = 0;
        for (int j: currorder){
            currans += j * (j + 1) / 2 + j * (n - j) + currsum * (n - j - currsum);
            currsum += j;
        }
        answer = min(currans, answer);
    }
    cout << answer;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int j = 0; j < nums.size() - 1; j++) swap(currorder[j], currorder[j + (i / fact[nums.size() - j - 1]) % (nums.size() - j)]);
      |                         ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 500 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 5 ms 500 KB Output is correct
8 Correct 41 ms 348 KB Output is correct
9 Correct 482 ms 412 KB Output is correct
10 Correct 6094 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 57 ms 408 KB Output is correct
5 Incorrect 523 ms 408 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 57 ms 408 KB Output is correct
5 Incorrect 523 ms 408 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 57 ms 408 KB Output is correct
5 Incorrect 523 ms 408 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 500 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 5 ms 500 KB Output is correct
8 Correct 41 ms 348 KB Output is correct
9 Correct 482 ms 412 KB Output is correct
10 Correct 6094 ms 404 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 7 ms 344 KB Output is correct
14 Correct 57 ms 408 KB Output is correct
15 Incorrect 523 ms 408 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 500 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 5 ms 500 KB Output is correct
8 Correct 41 ms 348 KB Output is correct
9 Correct 482 ms 412 KB Output is correct
10 Correct 6094 ms 404 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 7 ms 344 KB Output is correct
14 Correct 57 ms 408 KB Output is correct
15 Incorrect 523 ms 408 KB Output isn't correct
16 Halted 0 ms 0 KB -