# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
474648 | 2021-09-19T09:00:55 Z | MilosMilutinovic | Diversity (CEOI21_diversity) | C++14 | 7000 ms | 2380 KB |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 500; int A[N], n, q, cnt[N], B[N]; int ans[N]; int main(){ scanf("%d%d", &n, &q); for(int i = 1;i <= n;i++){ scanf("%d", A + i); cnt[A[i]]++; } for(int i = 1;i <= q;i++){ int l, r; scanf("%d%d", &l, &r); } iota(B, B + N, 0); sort(B, B + N, [&](int i, int j){ return cnt[i] < cnt[j]; }); int l = 1, r = n; for(int i = 1;i <= N;i++){ for(int j = 1;j <= cnt[B[i]];j++){ if(i & 1) ans[l++] = B[i]; else ans[r--] = B[i]; } } long long sum = 0; for(int i = 1;i <= n;i++){ map < int, int > bio; int diff = 0; for(int j = i;j <= n;j++){ if(!bio[ans[j]]) diff++; bio[ans[j]]++; sum += diff; } } printf("%lld", sum); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1484 KB | Output is correct |
2 | Correct | 7 ms | 1484 KB | Output is correct |
3 | Correct | 7 ms | 1484 KB | Output is correct |
4 | Correct | 7 ms | 1484 KB | Output is correct |
5 | Correct | 7 ms | 1484 KB | Output is correct |
6 | Correct | 7 ms | 1484 KB | Output is correct |
7 | Correct | 7 ms | 1484 KB | Output is correct |
8 | Correct | 7 ms | 1484 KB | Output is correct |
9 | Correct | 7 ms | 1484 KB | Output is correct |
10 | Correct | 7 ms | 1420 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1484 KB | Output is correct |
2 | Correct | 10 ms | 1492 KB | Output is correct |
3 | Correct | 306 ms | 1560 KB | Output is correct |
4 | Execution timed out | 7036 ms | 2380 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1484 KB | Output is correct |
2 | Correct | 10 ms | 1492 KB | Output is correct |
3 | Correct | 306 ms | 1560 KB | Output is correct |
4 | Execution timed out | 7036 ms | 2380 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1484 KB | Output is correct |
2 | Correct | 10 ms | 1492 KB | Output is correct |
3 | Correct | 306 ms | 1560 KB | Output is correct |
4 | Execution timed out | 7036 ms | 2380 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1484 KB | Output is correct |
2 | Correct | 7 ms | 1484 KB | Output is correct |
3 | Correct | 7 ms | 1484 KB | Output is correct |
4 | Correct | 7 ms | 1484 KB | Output is correct |
5 | Correct | 7 ms | 1484 KB | Output is correct |
6 | Correct | 7 ms | 1484 KB | Output is correct |
7 | Correct | 7 ms | 1484 KB | Output is correct |
8 | Correct | 7 ms | 1484 KB | Output is correct |
9 | Correct | 7 ms | 1484 KB | Output is correct |
10 | Correct | 7 ms | 1420 KB | Output is correct |
11 | Correct | 8 ms | 1484 KB | Output is correct |
12 | Correct | 10 ms | 1492 KB | Output is correct |
13 | Correct | 306 ms | 1560 KB | Output is correct |
14 | Execution timed out | 7036 ms | 2380 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1484 KB | Output is correct |
2 | Correct | 7 ms | 1484 KB | Output is correct |
3 | Correct | 7 ms | 1484 KB | Output is correct |
4 | Correct | 7 ms | 1484 KB | Output is correct |
5 | Correct | 7 ms | 1484 KB | Output is correct |
6 | Correct | 7 ms | 1484 KB | Output is correct |
7 | Correct | 7 ms | 1484 KB | Output is correct |
8 | Correct | 7 ms | 1484 KB | Output is correct |
9 | Correct | 7 ms | 1484 KB | Output is correct |
10 | Correct | 7 ms | 1420 KB | Output is correct |
11 | Correct | 8 ms | 1484 KB | Output is correct |
12 | Correct | 10 ms | 1492 KB | Output is correct |
13 | Correct | 306 ms | 1560 KB | Output is correct |
14 | Execution timed out | 7036 ms | 2380 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |