Submission #881504

# Submission time Handle Problem Language Result Execution time Memory
881504 2023-12-01T10:27:22 Z Yang8on Sjeckanje (COCI21_sjeckanje) C++14
15 / 110
2000 ms 2648 KB
#include <bits/stdc++.h>

#define Yang8on Nguyen_Dinh_Son
#define sonphamay Nguyen_Dinh_Son

#define aothtday "Sjeckanje"
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define ll long long
#define endl '\n'
#define pii pair<int, ll>
#define pb push_back
#define all(v) v.begin(), v.end()
#define f first
#define s second
#define maxn 200005
#define maxm
#define maxx
#define mod 1000000007
#define base 311
#define ModHas 1000000003ll
#define gb(i, j) ((i >> j) & 1)
#define int long long

using namespace std;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll GetRandom(ll l, ll r)
{
    return uniform_int_distribution<ll> (l, r)(rng);
}

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

void solve()
{
    cin >> n >> q;
    fi(i, 1, n) cin >> a[i];

    fi(_, 1, q)
    {
        int l, r;
        ll val;
        cin >> l >> r >> val;

        fi(i, l, r) a[i] += val;
        fi(i, 1, n) fi(j, 1, i) dp[i] = max(dp[i], abs(a[i] - a[j]) + dp[j - 1]);

        cout << dp[n] << '\n';

        fi(i, 1, n) dp[i] = 0;
    }
}

signed main()
{
    if(fopen(aothtday".inp", "r"))
    {
        freopen(aothtday".inp","r",stdin);
        freopen(aothtday".out","w",stdout);
    }

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int nTest = 1;
//    cin >> nTest;

    while(nTest --)
    {
        solve();
    }

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(aothtday".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(aothtday".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2396 KB Output is correct
2 Correct 5 ms 2396 KB Output is correct
3 Correct 5 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 5 ms 2392 KB Output is correct
6 Correct 5 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2396 KB Output is correct
2 Correct 5 ms 2396 KB Output is correct
3 Correct 5 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 5 ms 2392 KB Output is correct
6 Correct 5 ms 2648 KB Output is correct
7 Execution timed out 2023 ms 2396 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2396 KB Output is correct
2 Correct 5 ms 2396 KB Output is correct
3 Correct 5 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 5 ms 2392 KB Output is correct
6 Correct 5 ms 2648 KB Output is correct
7 Execution timed out 2023 ms 2396 KB Time limit exceeded
8 Halted 0 ms 0 KB -