Submission #1054016

# Submission time Handle Problem Language Result Execution time Memory
1054016 2024-08-12T04:39:16 Z sleepntsheep Diversity (CEOI21_diversity) C++14
0 / 100
1 ms 348 KB
#include <cstdio>
#include <algorithm>
#define N 300001

int n, q, a[N];
long long z, y;

int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);

  std::sort(a + 1, a + 1 + n);

  for (int c = 1, f = 0, i = n; i >= 1; --i) {
    z += (n - i + 1) * c - y;

    if (a[i] != a[i - 1]) {
        y += c;
      ++c;
    } else {
      y += c - 1;
    }
  }

  printf("%lld", z);

}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:14:19: warning: unused variable 'f' [-Wunused-variable]
   14 |   for (int c = 1, f = 0, i = n; i >= 1; --i) {
      |                   ^
diversity.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
diversity.cpp:10:37: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   for (int i = 1; i <= n; ++i) scanf("%d", a + i);
      |                                ~~~~~^~~~~~~~~~~~~
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 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 Incorrect 0 ms 348 KB Output isn't correct
4 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -