# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
957311 | 2024-04-03T13:20:45 Z | LucaIlie | Diversity (CEOI21_diversity) | C++17 | 25 ms | 2644 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5; const int MAX_A = 3e5; int a[MAX_N + 1]; long long gauss( int n ) { return (long long)n * (n + 1) / 2; } int main() { int n, q; cin >> n >> q; for ( int i = 1; i <= n; i++ ) cin >> a[i]; while ( q-- ) { int l, r; cin >> l >> r; unordered_map<int, int> mp; for ( int i = l; i <= r; i++ ) mp[a[i]]++; vector<int> v; for ( auto p: mp ) v.push_back( p.second ); sort( v.begin(), v.end() ); vector<int> f( v.size() ); for ( int i = 0; i < v.size(); i++ ) { if ( i % 2 == 0 ) f[i / 2] = v[i]; else f[v.size() - 1 - i / 2] = v[i]; } int n = r - l + 1; long long ans = 0, k = 0; for ( int i = 0; i < f.size(); i++ ) { ans = ans + gauss( n - k ) - gauss( n - k - f[i] ) + (long long)k * (n - k); k += f[i]; } cout << ans << "\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 0 ms | 452 KB | Output is correct |
7 | Correct | 0 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 | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 344 KB | Output is correct |
4 | Correct | 12 ms | 900 KB | Output is correct |
5 | Correct | 23 ms | 1368 KB | Output is correct |
6 | Runtime error | 25 ms | 2644 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 344 KB | Output is correct |
4 | Correct | 12 ms | 900 KB | Output is correct |
5 | Correct | 23 ms | 1368 KB | Output is correct |
6 | Runtime error | 25 ms | 2644 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 344 KB | Output is correct |
4 | Correct | 12 ms | 900 KB | Output is correct |
5 | Correct | 23 ms | 1368 KB | Output is correct |
6 | Runtime error | 25 ms | 2644 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 0 ms | 452 KB | Output is correct |
7 | Correct | 0 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 | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 12 ms | 900 KB | Output is correct |
15 | Correct | 23 ms | 1368 KB | Output is correct |
16 | Runtime error | 25 ms | 2644 KB | Execution killed with signal 11 |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 0 ms | 452 KB | Output is correct |
7 | Correct | 0 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 | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 12 ms | 900 KB | Output is correct |
15 | Correct | 23 ms | 1368 KB | Output is correct |
16 | Runtime error | 25 ms | 2644 KB | Execution killed with signal 11 |
17 | Halted | 0 ms | 0 KB | - |