Submission #401770

# Submission time Handle Problem Language Result Execution time Memory
401770 2021-05-10T19:45:35 Z NintsiChkhaidze Sjeckanje (COCI21_sjeckanje) C++14
15 / 110
2000 ms 456 KB
#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;
    }
}

Compilation message

Main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main (){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 204 KB Output is correct
2 Correct 12 ms 328 KB Output is correct
3 Correct 9 ms 332 KB Output is correct
4 Correct 9 ms 340 KB Output is correct
5 Correct 9 ms 320 KB Output is correct
6 Correct 11 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 204 KB Output is correct
2 Correct 12 ms 328 KB Output is correct
3 Correct 9 ms 332 KB Output is correct
4 Correct 9 ms 340 KB Output is correct
5 Correct 9 ms 320 KB Output is correct
6 Correct 11 ms 332 KB Output is correct
7 Execution timed out 2073 ms 456 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 204 KB Output is correct
2 Correct 12 ms 328 KB Output is correct
3 Correct 9 ms 332 KB Output is correct
4 Correct 9 ms 340 KB Output is correct
5 Correct 9 ms 320 KB Output is correct
6 Correct 11 ms 332 KB Output is correct
7 Execution timed out 2073 ms 456 KB Time limit exceeded
8 Halted 0 ms 0 KB -