• API
• FAQ
• Tools
• Archive
daily pastebin goal
34%
SHARE
TWEET

# Untitled

a guest Mar 20th, 2019 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import sys
2.
3. def status(red, green, time):
4.     if time < red:
5.         a = ['Red', red - time]
6.         return a
7.     else:
8.         i = 0
9.         j = 0
10.         while i < time:
11.             if j % 2 == 0:
12.                 i += red
13.             else:
14.                 i += green
15.             j += 1
16.         if j % 2 == 0:
17.             a = ['Green']
18.         else:
19.             a = ['Red', i - time]
20.         return a
21.
22. def main():
24.     L = int(s[0])
25.     D = [int(s[i]) for i in range(len(s)) if i % 3 == 1]
26.     R = [int(s[i]) for i in range(len(s)) if i % 3 == 2]
27.     G = [int(s[i]) for i in range(1, len(s)) if i % 3 == 0]
28.     time = 0
29.     distance = 0
30.     j = 0
31.     while distance < L:
32.         if distance not in D:
33.             distance += 1
34.             time += 1
35.         else:
36.             if status(R[j], G[j], time)[0] == 'Green':
37.                 distance += 1
38.                 time += 1
39.             elif status(R[j], G[j], time)[0] == 'Red':
40.                 time += status(R[j], G[j], time)[1]
41.                 distance += 1
42.                 time += 1
43.             j += 1
44.     print(time)
45.
46. if __name__ == '__main__':
47.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top