// UVa 957 - Popes #include <iostream> using namespace std; #define type unsigned long long int main() { type y, p; type s1, s2, s3; type a[100001]; while (cin >> y >> p) { for (type i = 0; i < p; i++) cin >> a[i]; s1 = 0; type j = 1; for (type i = 0; i < p; i++) { type lim = a[i] + y; while (j < p && a[j] < lim) j++; if (j - i > s1) { s1 = j - i; s2 = a[i]; s3 = a[j - 1]; } } cout << s1 << " " << s2 << " " << s3 << endl; } return 0; }
No comments:
Post a Comment