-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteManns_Adventure.cpp
More file actions
38 lines (33 loc) · 853 Bytes
/
ByteManns_Adventure.cpp
File metadata and controls
38 lines (33 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// Global setup for fast I/O
struct FastIO {
FastIO() {
ios_base::sync_with_stdio(false); // Disable C I/O synchronization
cin.tie(nullptr); // Untie cin and cout for faster input/output
}
} fast_io_setup; // This will be executed before main()
int main() {
ll t;
cin >> t;
while(t--){
ll n;
cin >> n;
vector<ll> a(n);
for (ll i = 0; i < n; i++)
cin >> a[i];
ll ans = 1,r = 1;
for (ll i = 1; i < n; i++){
if(a[i] - 1 == a[i - 1] || a[i] + 1 == a[i - 1] || a[i] == a[i - 1]){
r++;
ans = max(ans, r);
}
else{
r = 1;
}
}
cout << ans << endl;
}
}