#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "
#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back
void solve()
{
ll n, q;
cin >> n >> q;
ll d[n + 1] = {};
FOR(i, 1, n + 1) {
cin >> d[i];
}
vi diff;
FOR(i, 2, n + 1) {
diff.pb(d[i] - d[i - 1]);
}
ll ans = 1, cnt = 1;
FOR(i, 1, diff.size()) {
if(diff[i] != diff[i - 1]) {
cnt = 1;
} else {
++cnt;
}
ans = max(ans, cnt + 1);
}
while(q--) {
int t;
cin >> t;
if(t == 1) {
ll l, r, s, c;
cin >> l >> r >> s >> c;
} else if(t == 2) {
ll l, r, s, c;
cin >> l >> r >> s >> c;
ans = n;
} else {
ll l, r;
cin >> l >> r;
cout << ans << nl;
}
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
117 ms |
6876 KB |
Output is correct |
2 |
Correct |
75 ms |
500 KB |
Output is correct |
3 |
Correct |
73 ms |
548 KB |
Output is correct |
4 |
Correct |
80 ms |
588 KB |
Output is correct |
5 |
Correct |
98 ms |
556 KB |
Output is correct |
6 |
Correct |
71 ms |
636 KB |
Output is correct |
7 |
Correct |
90 ms |
540 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
123 ms |
6868 KB |
Output is correct |
12 |
Correct |
141 ms |
6860 KB |
Output is correct |
13 |
Correct |
121 ms |
6876 KB |
Output is correct |
14 |
Correct |
121 ms |
6852 KB |
Output is correct |
15 |
Correct |
121 ms |
6868 KB |
Output is correct |
16 |
Correct |
118 ms |
6872 KB |
Output is correct |
17 |
Correct |
126 ms |
6872 KB |
Output is correct |
18 |
Correct |
128 ms |
6880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
6876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
145 ms |
6876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
6876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
117 ms |
6876 KB |
Output is correct |
2 |
Correct |
75 ms |
500 KB |
Output is correct |
3 |
Correct |
73 ms |
548 KB |
Output is correct |
4 |
Correct |
80 ms |
588 KB |
Output is correct |
5 |
Correct |
98 ms |
556 KB |
Output is correct |
6 |
Correct |
71 ms |
636 KB |
Output is correct |
7 |
Correct |
90 ms |
540 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
123 ms |
6868 KB |
Output is correct |
12 |
Correct |
141 ms |
6860 KB |
Output is correct |
13 |
Correct |
121 ms |
6876 KB |
Output is correct |
14 |
Correct |
121 ms |
6852 KB |
Output is correct |
15 |
Correct |
121 ms |
6868 KB |
Output is correct |
16 |
Correct |
118 ms |
6872 KB |
Output is correct |
17 |
Correct |
126 ms |
6872 KB |
Output is correct |
18 |
Correct |
128 ms |
6880 KB |
Output is correct |
19 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |