提交时间:2023-12-16 09:07:31
运行 ID: 116199
#include<bits/stdc++.h> using namespace std; int a[1010]; int main(){ int n; int sum1 = 0; int sum2 = 0; int sum3 = 0; cin >> n; for(int i = 0;i < n;i++) cin >> a[i]; for(int i = 0;i < n-1;i+=2){ sum1 += a[i]; } for(int i = 1;i < n;i+=2){ sum2 += a[i]; } for(int i = n;i >= 2;i-=2){ sum3 += a[i]; } if(sum1 > sum2 && sum1 > sum3) cout << sum1; else if(sum2 > sum1 && sum2 > sum3) cout << sum2; else cout << sum3; return 0; }