#P11641. Regrading Exams Final Score
Regrading Exams Final Score
Regrading Exams Final Score
Little Xun participated in \( n \) exams. Initially, his scores for the \( i \)-th exam are given as \( a_i \). After all exams have been taken, his instructor Little You grades the exams.
The instructor is very strict. If the total score \( S = \sum_{i=1}^{n} a_i \) is greater than or equal to the threshold \( T \) (i.e. \( S \ge T \)), then he regrades all exams. In the regrading, the score for the \( i \)-th exam becomes \( b_i \), and the final total score is \( \sum_{i=1}^{n} b_i \). Otherwise, if \( S < T \), the final score remains \( S \).
Your task is to compute the final total score.
inputFormat
The first line contains two integers ( n ) and ( T ) separated by a space. The second line contains ( n ) integers ( a_1, a_2, \dots, a_n ) separated by spaces. The third line contains ( n ) integers ( b_1, b_2, \dots, b_n ) separated by spaces.
outputFormat
Output a single integer: the final total score of Little Xun.
sample
5 10
1 2 3 4 5
5 4 3 2 1
15