QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#479170 | #4925. Adjacent Pairs | Nevll# | 0 | 0ms | 3792kb | C++14 | 955b | 2024-07-15 15:36:25 | 2024-07-15 15:36:25 |
answer
# include <bits/stdc++.h>
# define ll long long
# define ld double
# define fi first
# define se second
# define pii pair<int, int>
# define pll pair<ll, ll>
using namespace std;
int main() {
int cases;
scanf("%d", &cases);
while(cases--) {
int N;
scanf("%d", &N);
map<int, int> M1, M2;
int a1 = 0, a2 = 0;
for(int i=0;i<N;i++) {
int x;
scanf("%d", &x);
if(i%2 == 1) {
M1[x]++;
} else {
M2[x]++;
}
}
vector<pii> c1, c2;
c1.clear();
c2.clear();
for(auto p : M1) c1.push_back(p);
for(auto p : M2) c2.push_back(p);
c1.push_back({-1, 0});
c2.push_back({-2, 0});
sort(c1.begin(), c1.end());
sort(c2.begin(), c2.end());
int ans;
if(c1.back().fi == c2.back().fi) ans = N - max(c1[c1.size() - 1].se + c2[c2.size() - 2].se, c1[c1.size() - 2].se + c2[c2.size() - 1].se);
else ans = N - c1.back().se - c2.back().se;
printf("%d\n", ans);
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 20
Accepted
time: 0ms
memory: 3772kb
input:
2 5 4 5 2 4 5 2 1 2
output:
3 0
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
1 9 1 2 1 2 3 1 2 1 2
output:
6
result:
ok single line: '6'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
1 7 6 5 4 1 2 6 5
output:
5
result:
ok single line: '5'
Test #4:
score: -20
Wrong Answer
time: 0ms
memory: 3792kb
input:
1 16 4 3 4 3 4 3 4 3 1 4 3 4 1 4 3 4
output:
8
result:
wrong answer 1st lines differ - expected: '10', found: '8'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%