# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011983 | 2024-07-01T13:25:25 Z | vantam | Sjeckanje (COCI21_sjeckanje) | C++17 | 2000 ms | 2556 KB |
#pragma GCC optimize("O3") #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> using namespace std; const int N=1005 ; long long i,j,n,q,type,l,r,x,ma,mi,lt,rt; long long a[200005],dp[200005] ; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define NAME "test" if(fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } cin >> n >> q; for(i=1;i<=n;i++) cin >> a[i] ; while(q--){ cin >> l >> r >> x ; for(i=l;i<=r;i++) a[i]+=x ; dp[0]=0 ; for(i=1;i<=n;i++){ ma=a[i]; mi=a[i]; dp[i]=-1e18; for(j=i;j>=1;j--){ ma=max(ma,a[j]) ; mi=min(mi,a[j]) ; dp[i]=max(dp[i], dp[j-1]+ma-mi) ; } } cout << dp[n] << '\n' ; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2396 KB | Output is correct |
2 | Correct | 5 ms | 2396 KB | Output is correct |
3 | Correct | 4 ms | 2528 KB | Output is correct |
4 | Correct | 5 ms | 2556 KB | Output is correct |
5 | Correct | 5 ms | 2396 KB | Output is correct |
6 | Correct | 5 ms | 2512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2396 KB | Output is correct |
2 | Correct | 5 ms | 2396 KB | Output is correct |
3 | Correct | 4 ms | 2528 KB | Output is correct |
4 | Correct | 5 ms | 2556 KB | Output is correct |
5 | Correct | 5 ms | 2396 KB | Output is correct |
6 | Correct | 5 ms | 2512 KB | Output is correct |
7 | Execution timed out | 2077 ms | 2396 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2396 KB | Output is correct |
2 | Correct | 5 ms | 2396 KB | Output is correct |
3 | Correct | 4 ms | 2528 KB | Output is correct |
4 | Correct | 5 ms | 2556 KB | Output is correct |
5 | Correct | 5 ms | 2396 KB | Output is correct |
6 | Correct | 5 ms | 2512 KB | Output is correct |
7 | Execution timed out | 2077 ms | 2396 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |