-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruisekiwa.py
79 lines (64 loc) · 2.38 KB
/
ruisekiwa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 累積和に関する問題を解いた。
N, Q = map(int, input().split())
admission_person_count_list = list(map(int, input().split()))
admission_total_person_list = [0] * (N + 1)
for i in range(N):
admission_total_person_list[i + 1] = admission_total_person_list[i] + admission_person_count_list[i]
for _ in range(Q):
L, R = map(int, input().split())
print(admission_total_person_list[R] - admission_total_person_list[L - 1])
# 別問題の解答
# Atcoder Lottery
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
total_win_count = [0] * (N + 1)
total_lose_count = [0] * (N + 1)
for i in range(N):
if A[i] == 1:
total_win_count[i + 1] += total_win_count[i] + 1
total_lose_count[i + 1] = total_lose_count[i]
else:
total_lose_count[i + 1] += total_lose_count[i] + 1
total_win_count[i + 1] += total_win_count[i]
for _ in range(Q):
L, R = map(int, input().split())
win_count = total_win_count[R] - total_win_count[L - 1]
lose_count = total_lose_count[R] - total_lose_count[L - 1]
if win_count > lose_count:
print("win")
elif win_count < lose_count:
print("lose")
else:
print("draw")
# 別問題の解答
# Atcoder Event Attendance
D = int(input())
N = int(input())
each_date_participant_number = [0] * (D + 1)
total_each_date_participant_number = [0] * (D + 1)
for _ in range(N):
L, R = map(int, input().split())
each_date_participant_number[L] += 1
if R != D:
each_date_participant_number[R + 1] -= 1
total_each_date_participant_number[0] = each_date_participant_number[0]
for i in range(D):
total_each_date_participant_number[i + 1] = total_each_date_participant_number[i] + each_date_participant_number[i + 1]
for i in range(D):
print(total_each_date_participant_number[i + 1])
# 別問題の解答
# Atcoder Convenience Store2
T = int(input())
N = int(input())
each_time_employees = [0] * (T + 1)
each_time_total_employees = [0] * (T)
for _ in range(N):
attendance_time, leaving_time = map(int, input().split())
each_time_employees[attendance_time] += 1
each_time_employees[leaving_time] -= 1
each_time_total_employees[0] = each_time_employees[0]
for i in range(T - 1):
each_time_total_employees[i + 1] = each_time_total_employees[i] + each_time_employees[i + 1]
for employees_number in each_time_total_employees:
print(employees_number)