제출 #401770

#제출 시각아이디문제언어결과실행 시간메모리
401770NintsiChkhaidzeSjeckanje (COCI21_sjeckanje)C++14
15 / 110
2073 ms456 KiB
#include <bits/stdc++.h> #define pb push_back #define s second #define f first #define ll long long #define int ll using namespace std; const int N = 3005; ll a[N],dp[N]; main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n,m; cin>>n>>m; for (int i=1;i<=n;i++) cin>>a[i]; while(m--){ int l,r,k; cin>>l>>r>>k; for (int i=l;i<=r;i++) a[i] += k; for (int i=0;i<=n;i++){ if (i > 0) dp[i] = max(dp[i-1],dp[i]); int mx = -1e18,mn=1e18; for (int j=i+1;j<=n;j++){ mx = max(mx,a[j]),mn = min(mn,a[j]); dp[j] = max(dp[j],dp[i] + mx - mn); } } cout<<dp[n]<<"\n"; for (int i=0;i<=n;i++) dp[i] = 0; } }

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

Main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main (){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...