Skip to content

Commit d2171e5

Browse files
author
IsHYuhi
committed
add ABC
1 parent 8d955ca commit d2171e5

File tree

8 files changed

+106
-0
lines changed

8 files changed

+106
-0
lines changed

ABC/ABC022/A.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
N, S, T = map(int, input().split())
2+
W = int(input())
3+
ans = 0
4+
if S<=W<=T:
5+
ans+=1
6+
for i in range(N-1):
7+
a = int(input())
8+
W += a
9+
if S<=W<=T:
10+
ans+=1
11+
12+
print(ans)

ABC/ABC022/B.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from collections import Counter
2+
n = int(input())
3+
4+
A = []
5+
for _ in range(n):
6+
a = int(input())
7+
A.append(a)
8+
A = Counter(A)
9+
keys = [v-1 for k, v in A.items() if v >= 2]
10+
print(sum(keys))

ABC/ABC023/A.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
S = list(input())
2+
ans = 0
3+
for i in S:
4+
ans += int(i)
5+
print(ans)

ABC/ABC023/B.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from collections import deque
2+
n = int(input())
3+
S = input()
4+
len(S)
5+
S = deque(S)
6+
ans = 0
7+
while len(S)>1:
8+
l = S.popleft()
9+
r = S.pop()
10+
ans += 1
11+
if len(S)%3 == 2:
12+
if not l==r=='b':
13+
print(-1)
14+
exit()
15+
elif len(S)%3 == 0:
16+
if not (l=='c' and r=='a'):
17+
print(-1)
18+
exit()
19+
elif len(S)%3 == 1:
20+
if not (l=='a' and r=='c'):
21+
print(-1)
22+
exit()
23+
24+
if len(S)==0:
25+
print(-1)
26+
exit()
27+
elif len(S)==1:
28+
if not 'b'==S.pop():
29+
print(-1)
30+
exit()
31+
print(ans)

ABC/ABC024/A.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
A, B, C, K = map(int, input().split())
2+
S, T = map(int, input().split())
3+
4+
discount = 0
5+
if S+T>=K:
6+
discount = -(S+T)*C
7+
print(A*S+B*T+discount)

ABC/ABC024/B.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
N, T = map(int, input().split())
2+
A = []
3+
for i in range(N):
4+
a = int(input())
5+
A.append(a)
6+
ans = 0
7+
for i in range(N-1):
8+
if A[i]+T<=A[i+1]:
9+
ans += T
10+
else:
11+
ans += (A[i+1]-A[i])
12+
print(ans+T)

ABC/ABC025/A.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import itertools
2+
S = list(input())
3+
N = int(input())
4+
lis = []
5+
S = sorted(S)
6+
i = (N-1)//5
7+
j = (N-1)%5
8+
print(S[i]+S[j])
9+

ABC/ABC025/B.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
N, A, B = map(int, input().split())
2+
position = 0
3+
for i in range(N):
4+
s, d = input().split()
5+
d = int(d)
6+
if d<A:
7+
d = A
8+
elif d>B:
9+
d = B
10+
if s == 'West':
11+
position -= d
12+
elif s == 'East':
13+
position += d
14+
15+
if position<0:
16+
print('West', abs(position))
17+
elif position>0:
18+
print('East', abs(position))
19+
else:
20+
print(0)

0 commit comments

Comments
 (0)