typedef long long LL; #define CLR(a) memset(a, 0, sizeof(a)) int main(){ int n, x, res = 0; cin >> n; deque<int> dq; for (int i = 1; i <= n; i++){ cin >> x; dq.push_back(x); } while (dq.size() > 1){ int a = dq.front(), b = dq.back(); dq.pop_front(); dq.pop_back(); while (a != b){ if (a < b){ while (a < b && !dq.empty()){ a += dq.front(); dq.pop_front(); res++; } if (a == b){ continue; } else if (dq.empty()){ res++; break; } } if (a > b){ while (a > b && !dq.empty()){ b += dq.back(); dq.pop_back(); res++; } if (a == b) continue; else if (dq.empty()){ res++; break; } } } } cout << res << endl; return 0; }
点赞 评论

相关推荐

vegetable_more_exercise:1-1.5万,没错啊,最少是1人民币,在区间内
点赞 评论 收藏
分享
牛客网
牛客企业服务