Submission #366694

# Submission time Handle Problem Language Result Execution time Memory
366694 2021-02-15T03:47:25 Z faustaadp Sjeckanje (COCI21_sjeckanje) C++17
0 / 110
3 ms 364 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int NN = 1e6 + 5;
const int mo = 1e9 + 7;
const ld eps = 1e-9;
ll n, q, a[NN];
ll ST[4 * NN][3][3];
void init(ll aa, ll bb, ll ee)
{
    if(aa == bb)
    {
        for(ll i = 0; i < 3; i++)
            for(ll j = 0; j < 3; j++)
            {
                if(i != 2 && j != 2)
                    ST[ee][i][j] = -1e18;
                else
                {
                    ll cst = 0;
                    if(i == 0)cst -= a[aa];
                    if(j == 0)cst -= a[aa];
                    if(i == 1)cst += a[aa];
                    if(j == 1)cst += a[aa];
                    ST[ee][i][j] = cst; 
                }
            }
    }
    else
    {
        ll ce = (aa + bb) / 2;
        init(aa, ce, ee * 2);
        init(ce + 1, bb, ee * 2 + 1);
        for(ll i = 0; i < 3; i++)
            for(ll j = 0; j < 3; j++)
            {
                ST[ee][i][j] = ST[ee * 2][i][0] + ST[ee * 2 + 1][1][j];
                ST[ee][i][j] = max(ST[ee][i][j], ST[ee * 2][i][1] + ST[ee * 2 + 1][0][j]);
                ST[ee][i][j] = max(ST[ee][i][j], ST[ee * 2][i][2] + ST[ee * 2 + 1][2][j]);
            }
    }

}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> q ;
    for(ll i = 1; i <= n; i++)
        cin >> a[i];
    init(1, n, 1);
    for(ll i = 1; i <= q; i++)
    {
        ll L, R, tam;
        cin >> L >> R >> tam;
        for(ll i = L; i <= R; i++)
            a[i] += tam;
        init(1, n, 1);
        cout << ST[1][2][2] << "\n";
    }
}
    
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -