oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

crossingroads Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

crossingroads.html

Problem Description

Rar the cat is walking to school. Rar is a very fortunate cat, the only separation between his school (S) and his house (H) is a road.

             S
o--------------------------o [Road]
                         H

However, he can only cross the road at 2 traffic junctures, noted by (o), one at each end of the road. With this, he wants to find out the length of the shortest path between his house and the school.

To simplify this problem, the traffic light on the left [in the diagram] will at the 0m mark. You will be provided with 3 numbers, l, the length of the road in metres, s, the distance from the school to the 0m mark (traffic light on the left) and h, the distance from Rar the cat's house to the 0m mark.

Assume that crossing the road does not incur to the total distance he has to walk.

Input

3 space-separated integers, l, s, h. You may assume all integers are not above 1000 and that s, h < l.

Output

Output the minimum distance Rar the cat has to walk, in order to reach his school.

Sample Input

8 5 7

Sample Output

4

Explanation of Sample Output

012345678
     S~~~
o-------o
       H~

Tags

Syntax

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
110041s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o crossingroads -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.