제출 #1261741

#제출 시각아이디문제언어결과실행 시간메모리
1261741KALARRYSjeckanje (COCI21_sjeckanje)C++20
15 / 110
2095 ms520 KiB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

long long N,Q,a[200005],dp[200005];

long long calc()
{
    long long ret = 0;
    for(int i = 1 ; i <= N ; i++)
    {
        dp[i] = dp[i-1];
        long long maxim = a[i];
        long long minim = a[i];
        for(int j = i-1 ; j >= 1 && (maxim==a[i]||minim==a[i]) ; j--)
        {
            if(a[j] <= maxim && a[j] >= minim)
                continue;
            maxim = max(maxim,a[j]);
            minim = min(minim,a[j]);
            dp[i] = max(dp[i],maxim - minim + dp[j-1]);
        }
    }
    return dp[N];
}

int main()
{
    scanf("%lld%lld",&N,&Q);
    for(int i = 1 ; i <= N ; i++)
        scanf("%lld",&a[i]);
    for(int l,r,x,i = 1 ; i <= Q ; i++)
    {
        scanf("%d%d%d",&l,&r,&x);
        for(int j = l ; j <= r ; j++)
            a[j] += x;
        printf("%lld\n",calc());
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%lld%lld",&N,&Q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d%d%d",&l,&r,&x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...