Doukasen

AtCoder
IDabc223_c
Time2000ms
Memory256MB
Difficulty
We have $N$ fuses connected in series. The $i$\-th fuse from the left has a length of $A_i$ centimeters and burns at a constant speed of $B_i$ centimeters per second. Consider igniting this object from left and right ends simultaneously. Find the distance between the position where the two flames will meet and the left end of the object. ## Constraints * $1 \leq N \leq 10^5$ * $1 \leq A_i,B_i \leq 1000$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_N$ $B_N$ [samples]
Samples
Input #1
3
1 1
2 1
3 1
Output #1
3.000000000000000

The two flames will meet at $3$ centimeters from the left end of the object.
Input #2
3
1 3
2 2
3 1
Output #2
3.833333333333333
Input #3
5
3 9
1 2
4 6
1 5
5 3
Output #3
8.916666666666668
API Response (JSON)
{
  "problem": {
    "name": "Doukasen",
    "description": {
      "content": "We have $N$ fuses connected in series. The $i$\\-th fuse from the left has a length of $A_i$ centimeters and burns at a constant speed of $B_i$ centimeters per second. Consider igniting this object fro",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc223_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have $N$ fuses connected in series. The $i$\\-th fuse from the left has a length of $A_i$ centimeters and burns at a constant speed of $B_i$ centimeters per second.\nConsider igniting this object fro...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments