Skip to content

Commit 3300221

Browse files
author
IsHYuhi
committed
ABC188-ABC195
1 parent 2620032 commit 3300221

File tree

23 files changed

+231
-0
lines changed

23 files changed

+231
-0
lines changed

ABC/ABC188/A.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
x, y = map(int, input().split())
2+
3+
if min(x, y) + 3 >max(x, y):
4+
print('Yes')
5+
else:
6+
print('No')

ABC/ABC188/B.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import numpy as np
2+
3+
n = int(input())
4+
a = np.array(list(map(int, input().split())))
5+
b = np.array(list(map(int, input().split())))
6+
7+
if not np.sum(a*b):
8+
print('Yes')
9+
else:
10+
print('No')

ABC/ABC188/C.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
n = int(input())
2+
a = list(map(int, input().split()))
3+
4+
print(a.index(min(max(a[:2**(n-1)]), max(a[2**(n-1):]))) + 1)

ABC/ABC189/A.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from collections import Counter
2+
s = Counter(list(input()))
3+
if len(s)==1:
4+
print('Won')
5+
else:
6+
print('Lost')

ABC/ABC189/B.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
n, x = map(int, input().split())
2+
vp = [list(map(int, input().split())) for _ in range(n)]
3+
total = 0
4+
for i in range(n):
5+
v, p = vp[i]
6+
total += v*p
7+
if total>x*100:
8+
print(i+1)
9+
exit()
10+
print(-1)

ABC/ABC189/C.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
n = int(input())
2+
a = list(map(int, input().split()))
3+
4+
def split_array(a, key):
5+
n = len(a)
6+
l, r = 0, 0
7+
new = []
8+
i = 0
9+
while i<n:
10+
if a[i]==key:
11+
r = i
12+
if l!=r:
13+
new.append(a[l:r])
14+
l = r+1
15+
16+
else:
17+
l += 1
18+
i += 1
19+
20+
if a[n-1]!=key:
21+
new.append(a[l:n])
22+
23+
return new
24+
25+
def dfs(a):
26+
if len(a)<=1:
27+
return min(a)
28+
min_a = min(a)
29+
max_a = min_a*len(a)
30+
for na in split_array(a, min_a):
31+
r = dfs(na)
32+
if r > max_a:
33+
max_a = r
34+
return max_a
35+
36+
print(dfs(a))

ABC/ABC190/A.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
a, b, c = map(int, input().split())
2+
b -= c
3+
if a>b:
4+
print('Takahashi')
5+
else:
6+
print('Aoki')

ABC/ABC190/B.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
n, s, d = map(int, input().split())
2+
3+
ans = 'No'
4+
for _ in range(n):
5+
x, y = map(int, input().split())
6+
if x<s and y>d:
7+
ans = 'Yes'
8+
print(ans)

ABC/ABC190/C.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
n, m = map(int, input().split())
2+
ab = [list(map(int, input().split())) for _ in range(m)]
3+
k = int(input())
4+
cd = [list(map(int, input().split())) for _ in range(k)]
5+
6+
def check(dishes):
7+
count = 0
8+
fill = [0]*n
9+
for i in dishes:
10+
fill[i-1] = 1
11+
for a, b in ab:
12+
if fill[a-1] and fill[b-1]:
13+
count += 1
14+
return count
15+
16+
17+
def dfs(li, i):
18+
if i >= k:
19+
return check(li)
20+
21+
left = dfs(li+[cd[i][0]], i+1)
22+
right = dfs(li+[cd[i][1]], i+1)
23+
24+
ans = max(left, right)
25+
26+
return ans
27+
28+
print(dfs([], 0))

ABC/ABC191/A.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
v, t, s, d = map(int, input().split())
2+
3+
if v*t <= d <= v*s:
4+
print('No')
5+
else:
6+
print('Yes')

ABC/ABC191/B.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import numpy as np
2+
n, x = map(int, input().split())
3+
a = list(map(int, input().split()))
4+
a = [str(i) for i in a if i != x]
5+
6+
print(' '.join(a))

ABC/ABC192/A.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
x = int(input())
2+
print(100-x%100)

ABC/ABC192/B.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
s = input()
2+
s1 = s[::2]
3+
s2 = s[1::2]
4+
for i, l in enumerate(s, 1):
5+
6+
if i%2==1 and (ord('a')<=ord(l)<=ord('z')):
7+
continue
8+
elif i%2==0 and (ord('A')<=ord(l)<=ord('Z')):
9+
continue
10+
else:
11+
print('No')
12+
exit()
13+
14+
print('Yes')

ABC/ABC192/C.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
n, k = map(str, input().split())
2+
k = int(''.join(k))
3+
4+
def g1(x):
5+
return int(''.join(sorted(x, reverse=True)))
6+
7+
def g2(x):
8+
return int(''.join(sorted(x)))
9+
10+
next = str(n)
11+
for i in range(k):
12+
next = list(str(g1(next)-g2(next)))
13+
14+
print(''.join(next))

ABC/ABC193/A.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
a, b = map(int, input().split())
2+
print(100*(1-b/a))

ABC/ABC193/B.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
n = int(input())
2+
apx = [list(map(int, input().split())) for _ in range (n)]
3+
m = float('inf')
4+
for a, p, x in apx:
5+
if x-a > 0:
6+
m = min(m, p)
7+
8+
m = -1 if m == float('inf') else m
9+
print(m)

ABC/ABC193/C.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
n = int(input())
2+
expressed = set()
3+
4+
for i in range(2, int(n**0.5)+1):
5+
k = i*i
6+
while k <= n:
7+
expressed.add(k)
8+
k *= i
9+
10+
print(n-len(expressed))

ABC/ABC194/A.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
a, b = map(int, input().split())
2+
3+
if a+b>=15 and b>=8:
4+
print(1)
5+
elif a+b>=10 and b>=3:
6+
print(2)
7+
elif a+b>=3:
8+
print(3)
9+
else:
10+
print(4)
11+

ABC/ABC194/B.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
n = int(input())
2+
3+
ab = [list(map(int, input().split())) for _ in range(n)]
4+
ab.sort(key=lambda x: x[0])
5+
a, b = ab.pop(0)
6+
ab.sort(key=lambda x: x[1])
7+
_, c = ab.pop(0)
8+
print(min(a+b, max(a,c)))

ABC/ABC194/C.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from collections import Counter
2+
n = int(input())
3+
a = Counter(list(map(int, input().split())))
4+
a = [[i, j] for i, j in a.items()]
5+
6+
ans = 0
7+
for i in range(len(a)):
8+
for j in range(i, len(a)):
9+
ans += (a[i][1]*a[j][1])*(a[i][0]-a[j][0])**2
10+
11+
print(ans)

ABC/ABC195/A.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
m, h = map(int, input().split())
2+
3+
if h%m==0:
4+
print('Yes')
5+
else:
6+
print('No')

ABC/ABC195/B.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
a, b, w = map(int, input().split())
2+
w = w*1000
3+
4+
if a+(w%a)/(w//a)<= b:
5+
r = 1 if w%b != 0 else 0
6+
print(w//b+r, w//a)
7+
8+
else:
9+
print('UNSATISFIABLE')
10+

ABC/ABC195/C.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import math
2+
n = int(input())
3+
p = int(math.log10(n))
4+
ans = 0
5+
for i in range(3, 16, 3):
6+
if p>=i:
7+
ans += n-10**i+1
8+
print(ans)

0 commit comments

Comments
 (0)