文章

3

粉丝

18

获赞

15

访问

841

头像
AC50%,求大佬答疑
P1664 中南大学机试题
发布于2025年3月13日 16:03
阅读数 164

#include<bits/stdc++.h>
using namespace std;

int main(){
    int a[100005];
    int dp[100005];
    int n;
    while(cin>>n){
        memset(a,0,sizeof(a));
        memset(dp,0,sizeof(dp));
        for(int i=0;i<n;i++) cin>>a[i];
        int res=0;
        int head=0;int tail=0;
        dp[0]=a[0];
        for(int i=1;i<n;i++){
            dp[i]=max(a[i],dp[i-1]+a[i]);
            if(res<dp[i]){
                res=dp[i];
                tail=i;
    &...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发