d784. 一、連續元素的和 - 高中生程式解題系統

本文最後更新於:2024年1月12日 下午

Zerojudge
解題紀錄

d784. 一、連續元素的和 - 高中生程式解題系統

Zerojudge-d784-2.cpp

// Author : ysh
// 06/10/2022 Fri 13:52:41.37
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;cin>>n;
    while(n--) {
        int m;cin>>m;vector<int>f(m);for(int &i : f) cin>>i;int mmax = INT_MIN;int ans = 0;for(int i : f) {ans = max(i,ans + i);mmax = max(mmax,ans);}cout<<mmax<<"\n";
    }
    return 0;
}

d784. 一、連續元素的和 - 高中生程式解題系統
http://mysh212.github.io/algosolution/Zerojudge-d784-2.cpp/
作者
ysh
發布於
2022年6月10日
更新於
2024年1月12日
許可協議