답안 #372739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
372739 2021-03-01T12:05:28 Z Nimbostratus Sjeckanje (COCI21_sjeckanje) C++17
0 / 110
9 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define cln(a,s) memset((a),0,sizeof((a)[0])*(s))
#define all(x) (x).begin() , (x).end()
#define fi first
#define se second
#define int long long
using pii = pair<int,int>;
using ll = long long;
const int maxn = 2e5 + 5;
const int inf = 1e9;
const int mod = 1e9+7;


int n,q,a[maxn],dp[maxn];

int32_t main () {
	//freopen("in","r",stdin); freopen("out","w",stdout);
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	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;
		dp[1] = 0;
		for(int i=2;i<=n;i++) {
			dp[i] = 0;
			int mn = inf , mx = -inf;
			for(int j=i;j>=1;j--) {
				mn = min(mn,a[j]);
				mx = max(mx,a[j]);
				dp[i] = max(dp[i],dp[j-1]+mx-mn);
			}
		}
		cout << dp[n] << endl;
	}

}	
	


# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -