提交时间:2023-12-29 13:00:21

运行 ID: 118239

#include <iostream> #include <vector> using namespace std; vector<int> a; int n,sum = 0,sum1 = 0,s; int main() { ios::sync_with_stdio(0); cin >> n; for(int i = 0;i < n;i++) { cin >> s; a.push_back(s); } for(int i = 0;i < n;i += 2) sum += a[i]; for(int i = 1;i < n;i += 2) sum1 += a[i]; int y = sum > sum1 ? sum : sum1; cout << y; }