Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n, t;
- cin >> n >> t;
- int a[t], i, j;
- for(i = 0; i < t; i++) cin >> a[i];
- int max = 0, sz, first, last;
- for(i = 0; i < t; i++)
- {
- for(j = i+1; j < t; j++)
- {
- if(a[j] - a[i] < n)
- {
- sz = j - i + 1;
- if(max < sz)
- {
- max = sz;
- first = a[i], last = a[j];
- }
- }
- else break;
- }
- }
- printf("%d %d %d\n", max, first, last);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement