标签:style blog class code tar color
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define max(a,b) ((a)>(b)?(a):(b)) #define INF 0x3f3f3f3f const int N = 5005; int t, n, k, i, start[N]; bool check(int s, int e) { return e - s <= k; } int main() { scanf("%d", &t); while (t--) { int ans = 0; scanf("%d%d", &n, &k); for (i = 0; i< n; i++) scanf("%d", &start[i]); sort(start, start + n); i = 0; while (i < n) { int sum = 1; while (i < n - 1 && ((sum == 1 && check(start[i], start[i + 1])) || (check(start[i], start[i + 1]) && check(start[i - 1], start[i + 1])))) sum++, i++; if (!check(start[i], start[i + 1]) || i == n - 1) i++; ans = max(ans, sum); } printf("%d\n", ans); } return 0; }
UVA 1372 - Log Jumping(推理),布布扣,bubuko.com
标签:style blog class code tar color
原文地址:http://blog.csdn.net/accelerator_/article/details/24930999