| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 39800 | plj2025 | 【BJ】T1 | C++ | 运行超时 | 0 | 1000 MS | 376 KB | 620 | 2026-02-02 15:03:51 |
#include <bits/stdc++.h> using namespace std; int a[100005]; void solve() { deque<int> dq; int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a+1, a+n+1); int maxn = -1e9; for (int i = 1; i <= n; i++) { dq.push_back(a[i]); if ((dq.size() >= 2) && (1 < (dq[dq.size()-1]-dq[dq.size()-2]))) dq.empty(); while (k < (dq[dq.size()-1]-dq[0])) { dq.pop_front(); } // cout << dq.size() << endl; maxn=max(maxn, int(dq.size())); } cout << maxn << endl; } int main() { int t; cin >> t; while (t--) { solve(); } return 0; }