Submission #977297

# Submission time Handle Problem Language Result Execution time Memory
977297 2024-05-07T17:06:09 Z mannshah1211 Diversity (CEOI21_diversity) C++17
14 / 100
936 ms 2140 KB
/**
 *  author: hashman
 *  created:
**/

#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() {
  cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

using Int = long long;

#define seg(n) (Int(n) * Int(n + 1)) / 2

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  } 
  vector<int> f(11);
  for (int i = 0; i < n; i++) {
    ++f[a[i]];
  }
  sort(f.begin(), f.end());
  Int mn = 1e18;
  do {
    Int cur = 0, sum = 0;
    for (int j = 0; j < 11; j++) {
      cur += seg(n) - seg(n - sum - f[j]) - seg(sum);
      sum += f[j];
    }
    mn = min(mn, cur);
  } while (next_permutation(f.begin(), f.end()));
  cout << mn << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 600 KB Output is correct
2 Correct 43 ms 448 KB Output is correct
3 Correct 154 ms 492 KB Output is correct
4 Correct 473 ms 856 KB Output is correct
5 Correct 916 ms 1628 KB Output is correct
6 Correct 930 ms 2136 KB Output is correct
7 Correct 927 ms 2004 KB Output is correct
8 Correct 918 ms 2140 KB Output is correct
9 Correct 927 ms 2140 KB Output is correct
10 Correct 925 ms 2140 KB Output is correct
11 Correct 919 ms 2136 KB Output is correct
12 Correct 922 ms 2140 KB Output is correct
13 Correct 924 ms 2136 KB Output is correct
14 Correct 930 ms 2140 KB Output is correct
15 Correct 936 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 600 KB Output is correct
2 Correct 43 ms 448 KB Output is correct
3 Correct 154 ms 492 KB Output is correct
4 Correct 473 ms 856 KB Output is correct
5 Correct 916 ms 1628 KB Output is correct
6 Correct 930 ms 2136 KB Output is correct
7 Correct 927 ms 2004 KB Output is correct
8 Correct 918 ms 2140 KB Output is correct
9 Correct 927 ms 2140 KB Output is correct
10 Correct 925 ms 2140 KB Output is correct
11 Correct 919 ms 2136 KB Output is correct
12 Correct 922 ms 2140 KB Output is correct
13 Correct 924 ms 2136 KB Output is correct
14 Correct 930 ms 2140 KB Output is correct
15 Correct 936 ms 2136 KB Output is correct
16 Incorrect 116 ms 432 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 600 KB Output is correct
2 Correct 43 ms 448 KB Output is correct
3 Correct 154 ms 492 KB Output is correct
4 Correct 473 ms 856 KB Output is correct
5 Correct 916 ms 1628 KB Output is correct
6 Correct 930 ms 2136 KB Output is correct
7 Correct 927 ms 2004 KB Output is correct
8 Correct 918 ms 2140 KB Output is correct
9 Correct 927 ms 2140 KB Output is correct
10 Correct 925 ms 2140 KB Output is correct
11 Correct 919 ms 2136 KB Output is correct
12 Correct 922 ms 2140 KB Output is correct
13 Correct 924 ms 2136 KB Output is correct
14 Correct 930 ms 2140 KB Output is correct
15 Correct 936 ms 2136 KB Output is correct
16 Incorrect 116 ms 432 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 43 ms 448 KB Output is correct
13 Correct 154 ms 492 KB Output is correct
14 Correct 473 ms 856 KB Output is correct
15 Correct 916 ms 1628 KB Output is correct
16 Correct 930 ms 2136 KB Output is correct
17 Correct 927 ms 2004 KB Output is correct
18 Correct 918 ms 2140 KB Output is correct
19 Correct 927 ms 2140 KB Output is correct
20 Correct 925 ms 2140 KB Output is correct
21 Correct 919 ms 2136 KB Output is correct
22 Correct 922 ms 2140 KB Output is correct
23 Correct 924 ms 2136 KB Output is correct
24 Correct 930 ms 2140 KB Output is correct
25 Correct 936 ms 2136 KB Output is correct
26 Incorrect 116 ms 432 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 43 ms 448 KB Output is correct
13 Correct 154 ms 492 KB Output is correct
14 Correct 473 ms 856 KB Output is correct
15 Correct 916 ms 1628 KB Output is correct
16 Correct 930 ms 2136 KB Output is correct
17 Correct 927 ms 2004 KB Output is correct
18 Correct 918 ms 2140 KB Output is correct
19 Correct 927 ms 2140 KB Output is correct
20 Correct 925 ms 2140 KB Output is correct
21 Correct 919 ms 2136 KB Output is correct
22 Correct 922 ms 2140 KB Output is correct
23 Correct 924 ms 2136 KB Output is correct
24 Correct 930 ms 2140 KB Output is correct
25 Correct 936 ms 2136 KB Output is correct
26 Incorrect 116 ms 432 KB Output isn't correct
27 Halted 0 ms 0 KB -