benchmarks.wiki / Public workspace
Humanity's Last Code Exam / 2017_E / Need for Speed
Problem
Answer published by the source. Consult the official source to check your work against its answer.
platform
atcoder
question content
**Problem Description**
Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when the speedometer reads , her true speed is , where is an unknown constant (possibly negative).
Sheila made a careful record of a recent journey and wants to use this to compute . The journey consisted of segments. In the segment she traveled a distance of and the speedometer read for the entire segment. This whole journey took time . Help Sheila by computing .
Note that while Sheila’s speedometer might have negative readings, her true speed was greater than zero for each segment of the journey.
**Input**
- The first line of input contains two integers (), the number of sections in Sheila’s journey, and (), the total time.
- This is followed by lines, each describing one segment of Sheila’s journey.
- The of these lines contains two integers () and (), the distance and speedometer reading for the segment of the journey. Time is specified in hours, distance in miles, and speed in miles per hour.
**Output**
- Display the constant in miles per hour. Your answer should have an absolute or relative error of less than .
**Sample Input 1**
Plain-text mathematical notation (without MathML)
**Problem Description** Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when the speedometer reads s, her true speed is s+c, where c is an unknown constant (possibly negative). Sheila made a careful record of a recent journey and wants to use this to compute c. The journey consisted of n segments. In the i^(th) segment she traveled a distance of d_(i) and the speedometer read s_(i) for the entire segment. This whole journey took time t. Help Sheila by computing c. Note that while Sheila’s speedometer might have negative readings, her true speed was greater than zero for each segment of the journey. **Input** - The first line of input contains two integers n (1≤n≤1000), the number of sections in Sheila’s journey, and t (1≤t≤10⁶), the total time. - This is followed by n lines, each describing one segment of Sheila’s journey. - The i^(th) of these lines contains two integers d_(i) (1≤d_(i)≤1000) and s_(i) (|s_(i)|≤1000), the distance and speedometer reading for the i^(th) segment of the journey. Time is specified in hours, distance in miles, and speed in miles per hour. **Output** - Display the constant c in miles per hour. Your answer should have an absolute or relative error of less than 10^(−6). **Sample Input 1**
Original LaTeX notation
**Problem Description**
Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when the speedometer reads \(s\), her true speed is \(s + c\), where \(c\) is an unknown constant (possibly negative).
Sheila made a careful record of a recent journey and wants to use this to compute \(c\). The journey consisted of \(n\) segments. In the \(i^{th}\) segment she traveled a distance of \(d_i\) and the speedometer read \(s_i\) for the entire segment. This whole journey took time \(t\). Help Sheila by computing \(c\).
Note that while Sheila’s speedometer might have negative readings, her true speed was greater than zero for each segment of the journey.
**Input**
- The first line of input contains two integers \(n\) (\(1 \leq n \leq 1000\)), the number of sections in Sheila’s journey, and \(t\) (\(1 \leq t \leq 10^6\)), the total time.
- This is followed by \(n\) lines, each describing one segment of Sheila’s journey.
- The \(i^{th}\) of these lines contains two integers \(d_i\) (\(1 \leq d_i \leq 1000\)) and \(s_i\) (\(|s_i| \leq 1000\)), the distance and speedometer reading for the \(i^{th}\) segment of the journey. Time is specified in hours, distance in miles, and speed in miles per hour.
**Output**
- Display the constant \(c\) in miles per hour. Your answer should have an absolute or relative error of less than \(10^{-6}\).
**Sample Input 1**
Code
3 5
4 -1
4 0
10 3
**Sample Output 1**
Code
3.000000000
**Sample Input 2**
Code
4 10
5 3
2 2
3 6
3 1
**Sample Output 2**
Code
-0.508653377
question title
Need for Speed
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import