General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
145372752 Practice:
BARBARIANNNNN
573E - 23 C++14 (GCC 6-32) Time limit exceeded on test 8 6000 ms 1180 KB 2022-02-06 14:18:44 2022-02-06 14:18:44
→ 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