#include <iostream> #include <vector> using namespace std; int main() { int n; int i, start, end, count; while (cin >> n) { vector<int> alldata(n); for (i = 0; i < n; i++) { cin >> alldata[i]; } start = 0; end = n-1; count = 0; while (start <= end) { if (alldata[start] < alldata[end]) { alldata[start+1] += alldata[start]; start++; count++; } else if (alldata[start] == alldata[end]) { start++; end--; } else { alldata[end-1] += alldata[end]; end--; count++; } } cout << count << endl; } return 0; }
点赞 3

相关推荐

牛客68151836...:实习不相关就靠后写吧,因为大概面试官也不感兴趣。前面区域写一点更容易引起提问的内容,比如投后台就把服务器项目提前。
简历上的经历如何包装
点赞 评论 收藏
分享
11-04 10:30
已编辑
门头沟学院 研发工程师
开心小狗🐶:“直接说答案”
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务