General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
145373496 Practice:
BARBARIANNNNN
573E - 23 C++20 (GCC 11-64) Accepted 3244 ms 1160 KB 2022-02-06 14:27:20 2022-02-06 14:27:20
→ Source
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
int n,a[100005];
long long dp[100005];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&a[i]);
	}
	for(int j=0; j<=n; j++) {
		dp[j]=(j==0?0:-inf);
	}
	for(int i=1; i<=n; i++) {
		for(int j=i; j>=1; j--) {
			dp[j]=max(dp[j],dp[j-1]+1ll*a[i]*j);
		}
	}
	long long ans=-inf;
	for(int j=0; j<=n; j++) {
		ans=max(ans,dp[j]);
	}
	printf("%lld",ans);
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details