제출 #412971

#제출 시각아이디문제언어결과실행 시간메모리
412971wiritos16Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
1 ms332 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll arr[200000]; ll izq[200000]; ll der[200000]; int main() { std::ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin>>n; for(ll i=0;i<n;i++) { cin>>arr[i]; } izq[0]=0; for(ll i=1;i<n;i++) { izq[i]=izq[i-1]+max((long long)0,arr[i-1]-arr[i]); } der[n-1]=0; for(ll i=n-2;i>=0;i--) { der[i]=der[i+1]+max((long long)0,arr[i+1]-arr[i]); } ll cont=0; for(ll i=0;i<n;i++) { cont=max(cont,max(der[i],izq[i])); } cout<<cont; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...