Skip to content

Commit 9275fb5

Browse files
authored
Create Punish the Students.py
1 parent c699793 commit 9275fb5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'''
2+
3+
Punish the Students
4+
https://practice.geeksforgeeks.org/problems/punish-the-students5726/1
5+
6+
'''
7+
8+
class Solution:
9+
def shouldPunish (self, roll, marks, n, avg):
10+
count = 0
11+
for i in range(n):
12+
for j in range(n - i - 2):
13+
if roll[j] > roll[j + 1]:
14+
temp = roll[j]
15+
roll[j] = roll[j+1]
16+
roll[j+1] = temp
17+
count +=2
18+
19+
if ((sum(marks) - count)/n) > avg:
20+
return 1
21+
else:
22+
return 0
23+
24+
25+
t = int (input ())
26+
for tc in range (t):
27+
n, avg = input ().split ()
28+
n = int (n)
29+
avg = float (avg)
30+
roll = list(map(int, input().split()))
31+
marks = list(map(int, input().split()))
32+
ob=Solution()
33+
print (ob.shouldPunish (roll, marks, n, avg))

0 commit comments

Comments
 (0)