提交时间:2024-01-07 15:09:17

运行 ID: 230036

#include<bits/stdc++.h> using namespace std; int n; vector<int> a; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; int sum = 0; for(int i = 0;i < n;i++) { int tmp; cin >> tmp; sum+=tmp; a.push_back(tmp); } int x,y; cin >> x >> y; int sh = 0; int ni = 0; x--; y--; for(int i = x;i < y;i++) { sh += a[i]; } ni = sum - sh; cout << min(sh,ni) << endl; return 0; }