QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#57826 | #4925. Adjacent Pairs | cheems_is_hiring | 0 | 2ms | 3612kb | C++ | 753b | 2022-10-23 01:59:33 | 2022-10-23 01:59:34 |
Judging History
answer
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ii pair<int,int>
const int mod = 1e9 + 7;
const int inf = 2e9 + 9;
const int N = 2e5 + 9;
void sol() {
int n; cin >> n;
int A[n];
map<int,int> M1, M2;
for(int i = 0 ; i < n ; i ++) {
cin >> A[i];
if(i % 2 == 0) M1[A[i]] ++;
else M2[A[i]] ++;
}
int x1 = -1;
int max1 = 0;
for(int i = 0 ; i < n ; i += 2)
if(M1[A[i]] > max1) x1 = A[i], max1 = M1[A[i]];
int max2 = 0;
for(int i = 1 ; i < n ; i += 2)
if(M2[A[i]] > max2 && A[i] != x1) max2 = M2[A[i]];
int a = (n / 2), b = n - a;
cout << (a - max1) + (b - max2) << endl;
}
int main() {
int t; cin >> t;
while(t --) sol();
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 20
Accepted
time: 1ms
memory: 3600kb
input:
2 5 4 5 2 4 5 2 1 2
output:
3 0
result:
ok 2 lines
Test #2:
score: -20
Wrong Answer
time: 2ms
memory: 3612kb
input:
1 9 1 2 1 2 3 1 2 1 2
output:
5
result:
wrong answer 1st lines differ - expected: '6', found: '5'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%