文章
34
粉丝
89
获赞
2
访问
19.1k
#include<cstdio> #include <iostream> #include<string> #include<algorithm> #include<vector> #include<climits> using namespace std; int a[10001]; int dp[10001]; int main() { int k; while (cin >> k) { if (k == 0) { break; } bool isAll = true; for (int i = 0; i < k; i++) { cin >> a[i]; if (a[i] >= 0) { isAll = false; } } int first; int end; if (isAll) {//全为负数 first = a[0]; end = a[k-1]; printf("%d %d %d\n", 0, first, end); } else { first = a[0]; int preFir = a[0]; end = a[0]; dp[0] = a[0]; int maxx = a[0]; for (int i = 1; i < k; i++) { if ((dp[i-1] + a[i]) < a[i]) { preFir = a[i]; ...
登录后发布评论
暂无评论,来抢沙发