QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#447920 | #4925. Adjacent Pairs | RaduM | 0 | 0ms | 3676kb | C++20 | 1.0kb | 2024-06-19 01:14:37 | 2024-06-19 01:14:38 |
answer
#include <bits/stdc++.h>
using namespace std;
vector < vector < pair <int, int> > > v(2);
vector < map <int, int> > mp(2);
int main()
{
int n,i,t,x;
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t;
while(t--){
cin >> n;
for(i = 1; i <= n; i++){
cin >> x;
mp[i & 1][x]++;
}
for(auto x : mp[0]) v[0].push_back({x.second, x.first});
for(auto x : mp[1]) v[1].push_back({x.second, x.first});
sort(v[0].rbegin(), v[0].rend());
sort(v[1].rbegin(), v[1].rend());
if(v[0][0].second != v[1][0].second) cout << n - v[0][0].first - v[1][0].first << "\n";
else{
int t1 = v[1][0].first, t2 = v[0][0].first;
if(v[0].size() > 1) t1 += v[0][1].first;
if(v[1].size() > 1) t2 += v[1][1].first;
cout << n - max(t1, t2) << "\n";
}
for(i = 0; i < 2; i++){
v[i].clear();
mp[i].clear();
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 20
Accepted
time: 0ms
memory: 3676kb
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: 0ms
memory: 3676kb
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%