Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7cd787d

Browse files
authored
Solution
1 parent 0089093 commit 7cd787d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the jumpingOnClouds function below.
10+
def jumpingOnClouds(c, k):
11+
e=100
12+
energy=0
13+
i=0
14+
while(i!=len(c)):
15+
if(c[i]==1):
16+
energy=e-3
17+
e=energy
18+
else:
19+
energy=e-1
20+
e=energy
21+
i+=k
22+
return energy
23+
24+
if __name__ == '__main__':
25+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
26+
27+
nk = input().split()
28+
29+
n = int(nk[0])
30+
31+
k = int(nk[1])
32+
33+
c = list(map(int, input().rstrip().split()))
34+
35+
result = jumpingOnClouds(c, k)
36+
37+
fptr.write(str(result) + '\n')
38+
39+
fptr.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /