Submission #912399

# Submission time Handle Problem Language Result Execution time Memory
912399 2024-01-19T11:53:25 Z Trisanu_Das Sjeckanje (COCI21_sjeckanje) C++17
55 / 110
30 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,q;
ll a[3005];
ll dp[3005];
int main(){
    scanf("%d%d",&n,&q);
    for (int i = 1; i <= n; i++){
        scanf("%lld",&a[i]);
    }
    for (int Q = 0; Q < q; Q++){
        int l,r;
        ll x;
        scanf("%d%d%lld",&l,&r,&x);
        for (int i = l ;i <= r; i++){
            a[i] += x;
        }
        ll A = -1000000000000000;
        ll B = -1000000000000000;
        for (int i = 1; i <= n; i++){
            A = max(A, dp[i-1]-a[i]);
            B = max(B, dp[i-1]+a[i]);
            dp[i] = max(A+a[i], B-a[i]);
            //printf("%lld ",dp[i]);
        }
        printf("%lld\n",dp[n]);
 
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d%d%lld",&l,&r,&x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 30 ms 576 KB Output is correct
8 Correct 30 ms 572 KB Output is correct
9 Correct 30 ms 600 KB Output is correct
10 Correct 30 ms 348 KB Output is correct
11 Correct 30 ms 604 KB Output is correct
12 Correct 30 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 30 ms 576 KB Output is correct
8 Correct 30 ms 572 KB Output is correct
9 Correct 30 ms 600 KB Output is correct
10 Correct 30 ms 348 KB Output is correct
11 Correct 30 ms 604 KB Output is correct
12 Correct 30 ms 600 KB Output is correct
13 Runtime error 1 ms 600 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -