Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define For(i,z) for (int i = 0; i < z; i ++)
  4. #define int long long
  5. #define double long double
  6. #define _ << " " <<
  7. #define e << "\n"
  8. #define f first
  9. #define s second
  10. #define pii pair<int,int>
  11. #define pdd pair<double, double>
  12. #define sqr(a) ((a)*(a))
  13.  
  14. #define INF 1e12
  15.  
  16. const int N = 5e5 + 10;
  17. const double EPS = 1e-6;
  18.  
  19. using namespace std;
  20.  
  21. int n, f, s;
  22.  
  23. vector <int> ar(N);
  24.  
  25.  
  26. void input() {
  27.     ios_base::sync_with_stdio(false);
  28.     cin.tie(0);
  29.  
  30.     cin >> n >> f >> s;
  31.     f--; s --;
  32.  
  33.     ar.resize(n);
  34.     For (i, n)
  35.         cin >> ar[i];
  36. }
  37.  
  38. int32_t main() {
  39.     input();
  40.  
  41.     int ans1 = 0;
  42.     int idx = f;
  43.     while (idx != s) {
  44.         ans1 += ar[idx];
  45.         idx = (idx + 1) % n;
  46.     }
  47.  
  48.     int ans2 = 0;
  49.     idx = f;
  50.     while (idx != s) {
  51.         idx = (idx - 1 + n) % n;
  52.         ans2 += ar[idx];
  53.     }
  54.  
  55.     cout << min(ans1, ans2) e;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement