답안 #376286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376286 2021-03-11T07:25:43 Z dantoh000 Sjeckanje (COCI21_sjeckanje) C++14
55 / 110
68 ms 620 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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 59 ms 364 KB Output is correct
8 Correct 68 ms 492 KB Output is correct
9 Correct 60 ms 620 KB Output is correct
10 Correct 61 ms 492 KB Output is correct
11 Correct 62 ms 492 KB Output is correct
12 Correct 59 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 59 ms 364 KB Output is correct
8 Correct 68 ms 492 KB Output is correct
9 Correct 60 ms 620 KB Output is correct
10 Correct 61 ms 492 KB Output is correct
11 Correct 62 ms 492 KB Output is correct
12 Correct 59 ms 492 KB Output is correct
13 Runtime error 2 ms 620 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -