Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
93927 只因你太美(Ikun 真爱粉) 22相差2的数的个数 C++ Accepted 1 MS 264 KB 464 2024-10-19 15:39:29

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 = 0; 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; }