제출 #1129904

#제출 시각아이디문제언어결과실행 시간메모리
1129904rayan_bdSjeckanje (COCI21_sjeckanje)C++20
0 / 110
5 ms320 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; #define getar(ar,n) for(ll i=1;i<=n;++i) cin>>ar[i] #define show(n) cout<<n<<'\n' #define all(v) v.begin(), v.end() #define br cout<<"\n" #define pb push_back #define nl '\n' #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ret return #define ll long long #define ld long double #define sza(x) ((int)x.size()) #define fi first #define se second const int mxN = 1e5 + 5; const ll MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; void lets_go() { ll n,q,l,r,v;cin>>n>>q; ll ar[n+1];getar(ar,n); while(q--){ cin>>l>>r>>v; for(ll i=l;i<=r;++i) ar[i]+=v; vector<ll> dp(n+1,0); ll ans=0; for(ll i=1;i<=n;++i){ ll mn=INF,mx=-INF; for(ll j=i;j>=1;--j){ mn=min(mn,ar[j]); mx=max(mx,ar[j]); dp[i]=max(dp[i],dp[j-1]+mx-mn); } } show(dp[n]); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); lets_go(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...