답안 #375187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
375187 2021-03-09T04:09:22 Z dimashii Sjeckanje (COCI21_sjeckanje) C++17
15 / 110
2000 ms 548 KB
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int mxN = 1e6 + 5, mod = 1e9 + 7;
const ll inf = 1e18;

ll n, q, a[mxN];

ll d[mxN];

int main() {
	ios :: sync_with_stdio(false), cin.tie(nullptr);
	cin >> n >> q;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	while (q--) {
		int l, r, x;
		cin >> l >> r >> x;
		for (int i = l; i <= r; ++i)
			a[i] += x;
		for (int i = 1; i <= n; ++i)
			d[i] = -inf;
		for (int i = 1; i <= n; ++i) {
			ll mn = inf, mx = -inf;
			for (int j = i; j > 0; j--) {
				mn = min(mn, a[j]);
				mx = max(mx, a[j]);
				d[i] = max(d[i], d[j - 1] + mx - mn);
			}
		}
		cout << d[n] << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Execution timed out 2078 ms 548 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Execution timed out 2078 ms 548 KB Time limit exceeded
8 Halted 0 ms 0 KB -