Submission #966611

#TimeUsernameProblemLanguageResultExecution timeMemory
966611Trisanu_DasDischarging (NOI20_discharging)C++17
47 / 100
299 ms20396 KiB
# include <bits/stdc++.h> using namespace std; long long b[1000005], n,a[1000005],mn,mx,raod,x,w,ww; pair <long long ,long long > dp[1000005]; int main() { cin>>n; a[0]=1e9; for (int i=1; i<=n; i++) { cin>>a[i]; mx=max(mx,a[i]); if (a[i]>a[i-1]) ww=1; } if (n>1500) { cout<<mx*n<<endl; return 0; } dp[0]={0,0}; dp[1]={a[1]+(n-1)*a[1],a[1]}; for (int i=2; i<=n; i++) { dp[i].first=1e18; x=0; for (int j=i; j>=1; j--) { x=max(x,a[j]); dp[i].first=min(dp[i].first, dp[j-1].first+(n-j+1)*x); } } cout<<dp[n].first; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...