QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#57826#4925. Adjacent Pairscheems_is_hiring0 2ms3612kbC++753b2022-10-23 01:59:332022-10-23 01:59:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-23 01:59:34]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3612kb
  • [2022-10-23 01:59:33]
  • 提交

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%