#GYM104599C. Model Accuracy
Model Accuracy
Description
Lazy Bob has created a machine learning model which receives one number as the input and outputs that number + 1 (a very interesting model, as you can see).
He has a list of $N$ ($1 ≤ N ≤ 10,000$) expected outputs $e_i$ and actual outputs $a_i$ ($1 ≤ e_i, a_i ≤ 10^9$), and he wants to find out the accuracy of his model. If an actual output is within $K$ ($0 ≤ K ≤ 100,000$) of its corresponding expected output, he counts it as the same (his model is not that good).
Output the model's accuracy as a percentage to the nearest integer (for example, if 8 out of 12 cases work as expected, that would be considered an accuracy of 67%) but do NOT include the percent sign in your answer. Check the Notes section if this is unclear.
Line 1: Two space-separated integers, $N$ and $K$.
Line 2…$N+1$: 2 space-separated integers $e_i$ and $a_i$.
Line 1: A percentage representing Bob's model's accuracy (to the nearest integer). It is guaranteed that the accuracy will never be < 0.01 away from the middle of two integers.
Input
Line 1: Two space-separated integers, $N$ and $K$.
Line 2…$N+1$: 2 space-separated integers $e_i$ and $a_i$.
Output
Line 1: A percentage representing Bob's model's accuracy (to the nearest integer). It is guaranteed that the accuracy will never be < 0.01 away from the middle of two integers.
5 3
3 6
7 3
1 10
8 7
11 11
60
Note
$1 ≤ N ≤ 10,000$
$0 ≤ K ≤ 100,000$
$1 ≤ a_i, e_i ≤ 10^9$
3 out of the 5 output pairs are within K of each other, which is why the accuracy is ⅗*100% = 60%. Drop the percent sign to get an answer of 60.