Skip to content

Commit bb47f48

Browse files
committed
Add python-correct
1 parent eb058b6 commit bb47f48

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

battle_royal/python-correct/SOLUTION

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Solution
4+
#c_solution(src='main.c') # -lm -O2 as default
5+
#cxx_solution(src='main.cc', flags=[]) # -std=c++11 -O2 as default
6+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main')
7+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=[])
8+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=['10_corner*.in'])
9+
#script_solution(src='main.sh') # shebang line is required
10+
#script_solution(src='main.pl') # shebang line is required
11+
script_solution(src='main.py') # shebang line is required
12+
#script_solution(src='main.rb') # shebang line is required
13+
#js_solution(src='main.js') # javascript (nodejs)
14+
#hs_solution(src='main.hs') # haskell (stack + ghc)
15+
#cs_solution(src='main.cs') # C# (mono)
16+
17+
## Score
18+
#expected_score(100)

battle_royal/python-correct/main.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/local/bin/python3
2+
# -*- coding: utf-8 -*-
3+
4+
def solve():
5+
kill = list(map(int,input().split()))
6+
kill.sort()
7+
8+
n = len(kill)
9+
alive = [1]*n
10+
11+
for i in range(n):
12+
rem = kill[i]
13+
for j in range(i):
14+
if rem == 0:
15+
break
16+
17+
if alive[j]:
18+
alive[j] = 0
19+
rem -= 1
20+
21+
assert rem == 0
22+
23+
print(sum(alive))
24+
25+
def main():
26+
for _ in range(int(input())):
27+
solve()
28+
29+
if __name__ == '__main__':
30+
main()

0 commit comments

Comments
 (0)