Submission #382833

# Submission time Handle Problem Language Result Execution time Memory
382833 2021-03-28T09:40:52 Z Slavita Sjeckanje (COCI21_sjeckanje) C++14
0 / 110
11 ms 364 KB
#include <bits/stdc++.h>
#define ve vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define si(v) (int)v.size()
#define en '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 228;
const int big = 1e9;
int n, q;
ll a[N];

int main(){
    iostream::sync_with_stdio(false); cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    while(q--){
        ull l, r, x;
        cin >> l >> r >> x;
        for (ull i = l; i <= r; i++) a[i] += x;
        ll mx = 0ll + -big;
        for (int i = 1; i <= n - 1; i++){
            ll mx1 = 0ll + -big, mx2 = 0ll + -big;
            ll mn1 = 0ll + big, mn2 = 0ll + big;
            for (int j = 1; j <= i; j++) {mx1 = max(mx1, a[j]); mn1 = min(mn1, a[j]);}
            for (int j = i + 1; j <= n; j++) {mx2 = max(mx2, a[j]); mn2 = min(mn2, a[j]);}
            mx = max((mx1 - mn1) + (mx2 - mn2), mx);
        }
        cout << mx << en;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -