标签:div nbsp 最大值 its clu ORC 连续 题解 codeforce
题目链接:https://codeforces.com/contest/1359/problem/D
枚举所有可能的情况,其中一定有一个是正确答案。
即每次枚举去掉的最大值,取最大连续子序列的和。
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n] = {}; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0; for (int maxn = 30; maxn >= -30; maxn--) { int sum = 0; for (int i = 0; i < n; i++) { sum = max(0, sum) + a[i]; ans = max(ans, sum - maxn); } } cout << ans << "\n"; }
Educational Codeforces Round 88 (Rated for Div. 2) D. Yet Another Yet Another Task
标签:div nbsp 最大值 its clu ORC 连续 题解 codeforce
原文地址:https://www.cnblogs.com/Kanoon/p/12989145.html