Submission #1052465

# Submission time Handle Problem Language Result Execution time Memory
1052465 2024-08-10T14:47:13 Z kunzaZa183 Diversity (CEOI21_diversity) C++17
38 / 100
7000 ms 13040 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  cin.tie(0)->ios::sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n,q;
  cin >> n>>q;
  vector<int> vi(n);
  for (auto &a : vi)
    cin >> a;
  for(int i=0;i<q;i++)
  {
    int l,r;
    cin>>l>>r;
  }
  map<int, int> mii;
  for (auto a : vi)
    mii[a]++;
  vector<pair<int, int>> vpii;
  for (auto a : mii)
    vpii.push_back(a);
  sort(vpii.begin(), vpii.end(),
       [](pair<int, int> a, pair<int, int> b) { return a.second > b.second; });
  deque<int> di;
  for (int i = 0; i < vpii.size(); i++)
    if (i % 2 == 0)
      di.push_back(vpii[i].second);
    else
      di.push_front(vpii[i].second);
  int ans = 0;
//  for (auto a : di)
//    cout << a << ' ';
//  cout << "\n";
  for (auto a : di)
    ans += a * (a + 1) / 2;
//  cout << ans << "\n";
  for (int i = 0; i < di.size(); i++)
    for (int j = i + 1; j < di.size(); j++) {
      ans += di[i] * di[j] * (j - i + 1);
    }
  cout << ans << '\n';
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:26:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int i = 0; i < vpii.size(); i++)
      |                   ~~^~~~~~~~~~~~~
diversity.cpp:38:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (int i = 0; i < di.size(); i++)
      |                   ~~^~~~~~~~~~~
diversity.cpp:39:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int j = i + 1; j < di.size(); j++) {
      |                         ~~^~~~~~~~~~~
# 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 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 4 ms 1248 KB Output is correct
5 Correct 12 ms 2396 KB Output is correct
6 Correct 13 ms 3448 KB Output is correct
7 Correct 13 ms 3424 KB Output is correct
8 Correct 12 ms 3420 KB Output is correct
9 Correct 12 ms 3420 KB Output is correct
10 Correct 12 ms 3420 KB Output is correct
11 Correct 12 ms 3468 KB Output is correct
12 Correct 13 ms 3420 KB Output is correct
13 Correct 14 ms 3308 KB Output is correct
14 Correct 12 ms 3420 KB Output is correct
15 Correct 20 ms 3440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 4 ms 1248 KB Output is correct
5 Correct 12 ms 2396 KB Output is correct
6 Correct 13 ms 3448 KB Output is correct
7 Correct 13 ms 3424 KB Output is correct
8 Correct 12 ms 3420 KB Output is correct
9 Correct 12 ms 3420 KB Output is correct
10 Correct 12 ms 3420 KB Output is correct
11 Correct 12 ms 3468 KB Output is correct
12 Correct 13 ms 3420 KB Output is correct
13 Correct 14 ms 3308 KB Output is correct
14 Correct 12 ms 3420 KB Output is correct
15 Correct 20 ms 3440 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 16 ms 2408 KB Output is correct
21 Correct 21 ms 3420 KB Output is correct
22 Correct 14 ms 3436 KB Output is correct
23 Correct 23 ms 3420 KB Output is correct
24 Correct 14 ms 3532 KB Output is correct
25 Correct 15 ms 3432 KB Output is correct
26 Correct 14 ms 3420 KB Output is correct
27 Correct 18 ms 3420 KB Output is correct
28 Correct 15 ms 3420 KB Output is correct
29 Correct 22 ms 3420 KB Output is correct
30 Correct 16 ms 3440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 4 ms 1248 KB Output is correct
5 Correct 12 ms 2396 KB Output is correct
6 Correct 13 ms 3448 KB Output is correct
7 Correct 13 ms 3424 KB Output is correct
8 Correct 12 ms 3420 KB Output is correct
9 Correct 12 ms 3420 KB Output is correct
10 Correct 12 ms 3420 KB Output is correct
11 Correct 12 ms 3468 KB Output is correct
12 Correct 13 ms 3420 KB Output is correct
13 Correct 14 ms 3308 KB Output is correct
14 Correct 12 ms 3420 KB Output is correct
15 Correct 20 ms 3440 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 16 ms 2408 KB Output is correct
21 Correct 21 ms 3420 KB Output is correct
22 Correct 14 ms 3436 KB Output is correct
23 Correct 23 ms 3420 KB Output is correct
24 Correct 14 ms 3532 KB Output is correct
25 Correct 15 ms 3432 KB Output is correct
26 Correct 14 ms 3420 KB Output is correct
27 Correct 18 ms 3420 KB Output is correct
28 Correct 15 ms 3420 KB Output is correct
29 Correct 22 ms 3420 KB Output is correct
30 Correct 16 ms 3440 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 4 ms 860 KB Output is correct
38 Correct 5 ms 1116 KB Output is correct
39 Correct 13 ms 1632 KB Output is correct
40 Correct 17 ms 2800 KB Output is correct
41 Correct 23 ms 4024 KB Output is correct
42 Correct 23 ms 3932 KB Output is correct
43 Correct 29 ms 4008 KB Output is correct
44 Correct 25 ms 3932 KB Output is correct
45 Correct 27 ms 3932 KB Output is correct
46 Correct 26 ms 3932 KB Output is correct
47 Correct 27 ms 4184 KB Output is correct
48 Correct 23 ms 3932 KB Output is correct
49 Correct 24 ms 4016 KB Output is correct
50 Correct 22 ms 4028 KB Output is correct
51 Correct 23 ms 3932 KB Output is correct
52 Correct 23 ms 3932 KB Output is correct
53 Correct 23 ms 3932 KB Output is correct
54 Correct 23 ms 3932 KB Output is correct
55 Correct 23 ms 3952 KB Output is correct
56 Correct 24 ms 3932 KB Output is correct
57 Correct 28 ms 3932 KB Output is correct
58 Correct 23 ms 3932 KB Output is correct
59 Correct 26 ms 3952 KB Output is correct
60 Correct 23 ms 3932 KB Output is correct
# 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 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 4 ms 1248 KB Output is correct
15 Correct 12 ms 2396 KB Output is correct
16 Correct 13 ms 3448 KB Output is correct
17 Correct 13 ms 3424 KB Output is correct
18 Correct 12 ms 3420 KB Output is correct
19 Correct 12 ms 3420 KB Output is correct
20 Correct 12 ms 3420 KB Output is correct
21 Correct 12 ms 3468 KB Output is correct
22 Correct 13 ms 3420 KB Output is correct
23 Correct 14 ms 3308 KB Output is correct
24 Correct 12 ms 3420 KB Output is correct
25 Correct 20 ms 3440 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 5 ms 1524 KB Output is correct
30 Correct 16 ms 2408 KB Output is correct
31 Correct 21 ms 3420 KB Output is correct
32 Correct 14 ms 3436 KB Output is correct
33 Correct 23 ms 3420 KB Output is correct
34 Correct 14 ms 3532 KB Output is correct
35 Correct 15 ms 3432 KB Output is correct
36 Correct 14 ms 3420 KB Output is correct
37 Correct 18 ms 3420 KB Output is correct
38 Correct 15 ms 3420 KB Output is correct
39 Correct 22 ms 3420 KB Output is correct
40 Correct 16 ms 3440 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 4 ms 860 KB Output is correct
48 Correct 5 ms 1116 KB Output is correct
49 Correct 13 ms 1632 KB Output is correct
50 Correct 17 ms 2800 KB Output is correct
51 Correct 23 ms 4024 KB Output is correct
52 Correct 23 ms 3932 KB Output is correct
53 Correct 29 ms 4008 KB Output is correct
54 Correct 25 ms 3932 KB Output is correct
55 Correct 27 ms 3932 KB Output is correct
56 Correct 26 ms 3932 KB Output is correct
57 Correct 27 ms 4184 KB Output is correct
58 Correct 23 ms 3932 KB Output is correct
59 Correct 24 ms 4016 KB Output is correct
60 Correct 22 ms 4028 KB Output is correct
61 Correct 23 ms 3932 KB Output is correct
62 Correct 23 ms 3932 KB Output is correct
63 Correct 23 ms 3932 KB Output is correct
64 Correct 23 ms 3932 KB Output is correct
65 Correct 23 ms 3952 KB Output is correct
66 Correct 24 ms 3932 KB Output is correct
67 Correct 28 ms 3932 KB Output is correct
68 Correct 23 ms 3932 KB Output is correct
69 Correct 26 ms 3952 KB Output is correct
70 Correct 23 ms 3932 KB Output is correct
71 Correct 8 ms 1236 KB Output is correct
72 Correct 8 ms 1200 KB Output is correct
73 Correct 13 ms 1112 KB Output is correct
74 Correct 12 ms 1076 KB Output is correct
75 Correct 8 ms 1116 KB Output is correct
76 Correct 29 ms 2136 KB Output is correct
77 Correct 29 ms 2128 KB Output is correct
78 Correct 49 ms 2216 KB Output is correct
79 Correct 32 ms 2140 KB Output is correct
80 Correct 49 ms 2140 KB Output is correct
81 Correct 100 ms 3932 KB Output is correct
82 Correct 98 ms 3932 KB Output is correct
83 Correct 99 ms 3876 KB Output is correct
84 Correct 99 ms 3924 KB Output is correct
85 Correct 100 ms 3844 KB Output is correct
86 Correct 336 ms 4896 KB Output is correct
87 Correct 338 ms 4904 KB Output is correct
88 Correct 330 ms 4804 KB Output is correct
89 Correct 350 ms 4828 KB Output is correct
90 Correct 329 ms 4800 KB Output is correct
91 Execution timed out 7068 ms 13040 KB Time limit exceeded
92 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 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 4 ms 1248 KB Output is correct
15 Correct 12 ms 2396 KB Output is correct
16 Correct 13 ms 3448 KB Output is correct
17 Correct 13 ms 3424 KB Output is correct
18 Correct 12 ms 3420 KB Output is correct
19 Correct 12 ms 3420 KB Output is correct
20 Correct 12 ms 3420 KB Output is correct
21 Correct 12 ms 3468 KB Output is correct
22 Correct 13 ms 3420 KB Output is correct
23 Correct 14 ms 3308 KB Output is correct
24 Correct 12 ms 3420 KB Output is correct
25 Correct 20 ms 3440 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 5 ms 1524 KB Output is correct
30 Correct 16 ms 2408 KB Output is correct
31 Correct 21 ms 3420 KB Output is correct
32 Correct 14 ms 3436 KB Output is correct
33 Correct 23 ms 3420 KB Output is correct
34 Correct 14 ms 3532 KB Output is correct
35 Correct 15 ms 3432 KB Output is correct
36 Correct 14 ms 3420 KB Output is correct
37 Correct 18 ms 3420 KB Output is correct
38 Correct 15 ms 3420 KB Output is correct
39 Correct 22 ms 3420 KB Output is correct
40 Correct 16 ms 3440 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 4 ms 860 KB Output is correct
48 Correct 5 ms 1116 KB Output is correct
49 Correct 13 ms 1632 KB Output is correct
50 Correct 17 ms 2800 KB Output is correct
51 Correct 23 ms 4024 KB Output is correct
52 Correct 23 ms 3932 KB Output is correct
53 Correct 29 ms 4008 KB Output is correct
54 Correct 25 ms 3932 KB Output is correct
55 Correct 27 ms 3932 KB Output is correct
56 Correct 26 ms 3932 KB Output is correct
57 Correct 27 ms 4184 KB Output is correct
58 Correct 23 ms 3932 KB Output is correct
59 Correct 24 ms 4016 KB Output is correct
60 Correct 22 ms 4028 KB Output is correct
61 Correct 23 ms 3932 KB Output is correct
62 Correct 23 ms 3932 KB Output is correct
63 Correct 23 ms 3932 KB Output is correct
64 Correct 23 ms 3932 KB Output is correct
65 Correct 23 ms 3952 KB Output is correct
66 Correct 24 ms 3932 KB Output is correct
67 Correct 28 ms 3932 KB Output is correct
68 Correct 23 ms 3932 KB Output is correct
69 Correct 26 ms 3952 KB Output is correct
70 Correct 23 ms 3932 KB Output is correct
71 Correct 8 ms 1236 KB Output is correct
72 Correct 8 ms 1200 KB Output is correct
73 Correct 13 ms 1112 KB Output is correct
74 Correct 12 ms 1076 KB Output is correct
75 Correct 8 ms 1116 KB Output is correct
76 Correct 29 ms 2136 KB Output is correct
77 Correct 29 ms 2128 KB Output is correct
78 Correct 49 ms 2216 KB Output is correct
79 Correct 32 ms 2140 KB Output is correct
80 Correct 49 ms 2140 KB Output is correct
81 Correct 100 ms 3932 KB Output is correct
82 Correct 98 ms 3932 KB Output is correct
83 Correct 99 ms 3876 KB Output is correct
84 Correct 99 ms 3924 KB Output is correct
85 Correct 100 ms 3844 KB Output is correct
86 Correct 336 ms 4896 KB Output is correct
87 Correct 338 ms 4904 KB Output is correct
88 Correct 330 ms 4804 KB Output is correct
89 Correct 350 ms 4828 KB Output is correct
90 Correct 329 ms 4800 KB Output is correct
91 Execution timed out 7068 ms 13040 KB Time limit exceeded
92 Halted 0 ms 0 KB -