码迷,mamicode.com
首页 > 其他好文 > 详细

Loj514「LibreOJ β Round #2」模拟只会猜题意 - 模拟

时间:2018-02-11 22:38:38      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:nbsp   sizeof   color   std   ++   false   eof   pos   cin   

  注意初始化即可。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int n,m,s[10005],a[10005],t1,t2,t3,t4;
 5 
 6 int main(){
 7     memset(a,0x80,sizeof a);
 8     ios::sync_with_stdio(false);
 9     cin>>n>>m;
10     for(int i=1;i<=n;i++) cin>>s[i], s[i]+=s[i-1];
11     for(int i=1;i<=n;i++) 
12         for(int j=0;j+i<=n;j++)
13             a[i]=max(a[i],s[i+j]-s[j]);
14     for(int i=n-1;i>=1;i--)
15         a[i]=max(a[i],a[i+1]);
16     for(int i=1;i<=m;i++) 
17         cin>>t1,
18         cout<<a[t1]<<endl;
19 }

 

Loj514「LibreOJ β Round #2」模拟只会猜题意 - 模拟

标签:nbsp   sizeof   color   std   ++   false   eof   pos   cin   

原文地址:https://www.cnblogs.com/mollnn/p/8443280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!