#include<iostream> using namespace std; int main(void) { int n; int temp; while (cin >> n) { int *length = new int[n]; int *Ei = new int[n]; for (int i = 0; i < n; i++) cin >> length[i]; for (int i = 0; i < n; i++) cin >> Ei[i]; temp = length[n-1]; if (n > 1) { for (int i = n - 1; i >= 0; i--) { if (i == n - 1) temp += Ei[i]; else temp += Ei[i] + length[i + 1] - length[i]; cout << temp + length[i]; if (i != 0) cout << endl; } } else { cout << Ei[0]+2*length[0]; } delete[] length; delete[] Ei; } return 0; } 也算是动态规划吧,AC了
点赞 3

相关推荐

星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
06-26 17:24
已编辑
宁波大学 golang
迷失西雅图:别给,纯kpi,别问我为什么知道
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务