RUVIDEO
Поделитесь видео 🙏

Grade Allocation from Codeforces (EPIC Runtime Error in C++)

Coding in C++ until 27:45 (EPIC FAIL - Cant find the error :((( )
Just coded it in python.

Grade Allocation

time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

n students are taking an exam. The highest possible score at this exam is m. Let ai be the score of the i-th student. You have access to the school database which stores the results of all students.

You can change each student's score as long as the following conditions are satisfied:

All scores are integers
0=ai=m
The average score of the class doesn't change.
You are student 1 and you would like to maximize your own score.

Find the highest possible score you can assign to yourself such that all conditions are satisfied.

Input
Each test contains multiple test cases.

The first line contains the number of test cases t (1=t=200). The description of the test cases follows.

The first line of each test case contains two integers n and m (1=n=103, 1=m=105) — the number of students and the highest possible score respectively.

The second line of each testcase contains n integers a1,a2,…,an (0=ai=m) — scores of the students.

Output
For each testcase, output one integer — the highest possible score you can assign to yourself such that both conditions are satisfied._

Example

input
2
4 10
1 2 3 4
4 5
1 2 3 4

output
10
5

Source Code:
def highest(a,m):
return m if sum(a)less_than m else sum(a)

//angle brackets are not allowed in description

for i in range(int(input())):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(highest(b,a[1]))

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Grade Allocation from Codeforces (EPIC Runtime Error in C++)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.