比赛 2024暑假C班集训9 评测结果 AWTTTTTTTTT
题目名称 (USACO Dec18)平衡木 最终得分 9
用户昵称 dream 运行时间 9.005 s
代码语言 C++ 内存使用 6.25 MiB
提交时间 2024-07-09 11:37:22
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int f[N];
int sum[N*2];
int cnt;
int n;
int main(){
    freopen("balance_beam.in","r",stdin);
    freopen("balance_beam.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>f[i];
    }
    for(int i=1;i<=n;i++){
        sum[i*2-1]=f[i-1];
        sum[i*2]=f[i+1];    
    }
//    for(int i=1;i<=n*2;i++){
//    	cout<<sum[i]<<" ";
//	}cout<<"\n\n";
    for(int i=1;i<=n;i++){
//    	cout<<"===========\n";
    	long long mx=-1;
    	mx=f[i]*100000;
        for(int j=i;j<=n;j++){
        	double qw=0;
//        	cout<<(j-i+1)<<"\n";
        	for(int q=i;q<=j;q++){
//        		cout<<sum[q*2-1]<<" "<<sum[q*2]<<"\n";
        		qw+=sum[q*2-1]*1.0/((j-i+1)*2);
        		qw+=sum[q*2]*1.0/((j-i+1)*2);
			}
//			cout<<"---"<<qw<<"\n";
			mx=max(mx,(long long)round(qw*100000));
        }
        for(int j=i;j>=1;j--){
//        	cout<<">>>>>"<<j<<"<<<<<"<<"\n";
//        	cout<<"adsfasfsadfads";
        	double qw=0;
//        	cout<<i<<"\n";
//        	cout<<sum[i*2-1]<<" "<<sum[i*2]<<"\n";
//        	cout<<j<<j<<j<<j<<j<<j<<j<<j<<j<<j<<j<<j<<"\n";
        	for(int q=i;q>=j;q--){
//        		cout<<"q "<<q<<"\n\n";
//        		cout<<q*2<<"\n";
//        		cout<<sum[q*2-1]<<" "<<sum[q*2]<<"\n";
        		qw+=sum[q*2-1]*1.0/(q*2);
        		qw+=sum[q*2]*1.0/(q*2);        		
			}
//			cout<<"\\\\\\\\\\\\ "<<qw<<"\n\n";
			mx=max(mx,(long long)round(qw*100000));
        }
        cout<<mx<<"\n";
    }
    return 0;
}