답안 #585109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585109 2022-06-28T10:09:59 Z keta_tsimakuridze Progression (NOI20_progression) C++17
15 / 100
19 ms 6804 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define f first
#define s second
#define endl "\n"
const int N = 2e5 + 5, mod = 1e9 + 7; //!
int t, d[N], a[N];
main() {
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n, q;
	cin >> n >> q;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(i > 1) {
			d[i - 1] = a[i] - a[i - 1];
		}
	}
	// ai - a(i - 1) - (a(i - 1) - a(i - 2)) = ai - 2*a(i-1) + a(i-2)

	for(int i = 1; i <= q; i++) {
		int t;
		cin >> t;
		if(t < 3) {
			int l, r, s, c;
			cin >> l >> r >> s >> c;
			if(t == 1)  {
				for(int j = l; j <= r; j++) a[j] += (j - l) * c + s;
			}
			else {
				for(int j = l; j <= r; j++) a[j] = (j - l) * c + s;
				
			}
			for(int j = 2; j <= n; j++) {
				d[j - 1] = a[j] - a[j - 1];
			}
			continue; 
		}
		int l, r;
		cin >> l >> r;
		int ans = 2;
		ans = min(ans, r - l + 1);
		r -= 1;
		for(int k = l; k <= r; k++) { 
			int j = k - 1;
			while(j < r  && d[k] == d[j + 1]) ++j;
			ans = max(ans, j - k + 2);
			k = j;
		}
		cout << ans << endl;
	}
}

Compilation message

Progression.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6708 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -