Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
106167 张永良 22相差2的数的个数 C++ Accepted 0 MS 268 KB 464 2025-01-15 15:25:56

Tests(2/2):


Code:

#include <bits/stdc++.h> using namespace std; int f[105]; int n; int main() { cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; f[num]++; } int maxn = 0; for (int i = 2; i <= 98; i++) { int c = f[i] + f[i + 1] + f[i + 2]; maxn = max(maxn, c); } maxn = max(maxn, f[99] + f[100]); maxn = max(maxn, f[100]); cout << maxn << endl; return 0; }