QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#156035#7112. XOR Cliqueucup-team1329#WA 10ms3824kbC++14958b2023-09-02 13:12:222023-09-02 14:42:36

Judging History

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

  • [2023-09-02 14:42:36]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3824kb
  • [2023-09-02 13:12:22]
  • 提交

answer

#include <bits/stdc++.h>

inline int read() {
    bool sym = false; int res = 0; char ch = getchar();
    while (!isdigit(ch)) sym |= (ch == '-'), ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    return sym ? -res : res;
}

void solve() {
    int n = read();
    std::vector<int> a(n + 1);
    std::map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        a[i] = read();
        mp[a[i]]++;
    }
    std::sort(a.begin() + 1, a.end());
    if (a[1] == a[n]) {
        printf("%d\n", n);
        return ;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i < n && a[i] % 2 == 0 && a[i + 1] == a[i] + 1) {
            ans = std::max(ans, mp[a[i]] + mp[a[i + 1]]);
        }
        ans = std::max(ans, mp[a[i]]);
    }
    printf("%d\n", ans);
}

int main() {
    int T = read();

    while (T--) {
        solve();
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3824kb

input:

3
3
1 2 3
3
1 1 1
5
1 2323 534 534 5

output:

2
3
2

result:

ok 3 number(s): "2 3 2"

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 3712kb

input:

10000
10
10 8 8 8 8 2 5 4 8 7
10
8 9 3 2 7 10 3 10 3 10
10
2 10 10 4 10 10 10 1 5 10
10
4 4 1 4 10 3 4 6 4 6
10
7 3 4 5 9 4 4 7 8 8
10
8 6 5 1 6 2 7 3 7 4
10
2 8 7 3 10 5 1 6 8 3
10
6 4 7 4 10 4 8 5 7 6
10
8 5 5 3 8 1 9 10 8 9
10
10 8 10 8 3 6 10 8 2 6
10
10 7 4 10 1 8 4 6 2 3
10
9 10 4 2 7 5 5 4 4 ...

output:

5
4
6
5
4
4
3
4
5
3
2
6
6
2
3
3
3
3
3
3
3
3
3
3
5
3
3
4
4
4
2
6
3
4
5
3
4
5
3
4
4
3
3
4
3
3
5
4
4
4
2
4
3
6
4
5
5
4
3
3
3
3
3
3
5
3
4
3
4
6
3
5
4
4
3
3
5
3
4
3
3
4
4
4
2
3
4
3
3
5
3
4
4
3
3
4
5
4
3
4
4
5
2
4
3
3
4
3
4
4
3
3
4
5
3
3
4
3
6
3
3
2
3
3
4
4
3
3
3
3
3
4
4
3
3
3
3
3
3
4
4
2
3
2
3
4
5
4
5
4
...

result:

wrong answer 1st numbers differ - expected: '6', found: '5'