Login
Register
Problem list
Online status
Huhu_Miao
:
2025-04-17 16:23:13
/** * author: Huhu_Miao * created: 2025.4.17 16:22:00 (UTC+8) **/ #include
#include
int arr[50001] , dp[50001]; void solve(){ int n; std::cin >> n; for(int i = 0 ; i < n; i++) std::cin >> arr[i]; dp[0] = arr[0]; for(int i = 1 ; i < n ; i++) dp[i] = std::max(dp[i-1] + arr[i] , arr[i]); std::cout << *std::max_element(dp, dp + n) << '\n'; } int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int T; std::cin>>T; while(T--) solve(); return 0; }
lin zehao
:
2023-04-27 17:12:37
极简主义 #include
using namespace std; int main() { int m, n, src; cin >> m; for (int i = 0; i < m; i++) { cin >> n; int temp_max = -1e9; int temp_last = -1e9; for (int j = 0; j < n; j++) { cin >> src; temp_last = max(temp_last + src, src); temp_max = max(temp_max, temp_last); } cout << temp_max << endl; } }
XianLYY
:
2022-05-08 22:15:10
1
吴卫为
:
2020-11-27 18:39:59
5 -1 -5 -2 -1 -3 输出的结果为什么不是5呢
Post Your Comment