report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Circle - MarisaOJ: Marisa Online Judge

Circle

Time limit: 1000 ms
Memory limit: 256 MB
Consider $n$ points lying on a circle. Let $A_i$ be the distance from point $i$ to $i+1$ on the circle. Find the shortest distance from point $x$ to point $y$ on the circle. ### Input - The first line consists of an integer $n$. - The second line contains $n$ integers $A_i$. Where $A_n$ is the distance from point $n$ to point $1$. - The third line contains two integers $x$ and $y$. ### Output - Output the shortest distance between points $x$ and $y$. ### Constraints - $1 \le n \le 1000$. - $1 \le x, y \le n$. - $1 \le A_i \le 1000$. ### Sample test ``` 3 1 2 2 1 3 ``` Output: ``` 2 ```
Array
Even elements
Smallest value
Average
Array reversal
Negative and positive
Consecutive differences
Largest value
Positive and negative
Dominant element
Second largest
Maximum product
Array rotation
Palindrome array
Circle
Insert
Positive subarray
Sorting
Similar Arrays
Unique
Unique 2
Frequent value
Most Frequent Value
Bitonic sequence
Swap
Topic
Basic
Rating 800
Solution (1) Solution