Submission #977875

#TimeUsernameProblemLanguageResultExecution timeMemory
977875CirclingDiversity (CEOI21_diversity)C++17
4 / 100
6244 ms604 KiB
/*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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...