Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define For(i,z) for (int i = 0; i < z; i ++)
- #define int long long
- #define double long double
- #define _ << " " <<
- #define e << "\n"
- #define f first
- #define s second
- #define pii pair<int,int>
- #define pdd pair<double, double>
- #define sqr(a) ((a)*(a))
- #define INF 1e12
- const int N = 5e5 + 10;
- const double EPS = 1e-6;
- using namespace std;
- int n, f, s;
- vector <int> ar(N);
- void input() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cin >> n >> f >> s;
- f--; s --;
- ar.resize(n);
- For (i, n)
- cin >> ar[i];
- }
- int32_t main() {
- input();
- int ans1 = 0;
- int idx = f;
- while (idx != s) {
- ans1 += ar[idx];
- idx = (idx + 1) % n;
- }
- int ans2 = 0;
- idx = f;
- while (idx != s) {
- idx = (idx - 1 + n) % n;
- ans2 += ar[idx];
- }
- cout << min(ans1, ans2) e;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement