标签:first href people poj sep fluent arch namespace case
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 14435 | Accepted: 3996 | |
Case Time Limit: 1000MS | Special Judge |
Description
Input
Output
Sample Input
6 3 1 6 4 5 2
Sample Output
60 3 5
Source
#include<iostream> #include<cstdio> using namespace std; #define N 100050 long long sum[N],l[N],r[N],a[N]; long long n,L,R; long long ans,maxx=-1; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); l[i]=r[i]=i; sum[i]=sum[i-1]+a[i]; } a[0]=a[n+1]=-1; for(int i=1;i<=n;i++) { while(a[i]<=a[l[i]-1]) l[i]=l[l[i]-1]; } for(int i=n;i>=1;i--) { while(a[i]<=a[r[i]+1]) r[i]=r[r[i]+1]; } for(int i=1;i<=n;i++) { ans=(sum[r[i]]-sum[l[i]-1])*a[i]; if(ans>maxx) { maxx=ans; L=l[i]; R=r[i]; } } printf("%lld\n%lld %lld",maxx,L,R); return 0; }
标签:first href people poj sep fluent arch namespace case
原文地址:http://www.cnblogs.com/zzyh/p/6852056.html