-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc330_b.py
More file actions
71 lines (67 loc) · 1.51 KB
/
abc330_b.py
File metadata and controls
71 lines (67 loc) · 1.51 KB
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
//abc330_b.py
####################################
####################################
####################################
####################################
####################################
####################################
n, l, r = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
for i in range(n):
if a[i] < l:
print(l, end=" ")
elif r < a[i]:
print(r, end=" ")
else:
print(a[i], end=" ")
print("")
####################################
N, L, R = map(int, input().split())
A = list(map(int, input().split()))
ans = []
for num in A:
if num <= L:
ans.append(L)
elif num >= R:
ans.append(R)
else:
ans.append(num)
print(' '.join(map(str, ans)))
####################################
import sys
input = sys.stdin.readline
N,L,R=map(int,input().split())
A=list(map(int,input().split()))
for a in A:
if L<=a<=R:
print(a)
elif a<L:
print(L)
else:
print(R)
####################################
N,L,R=map(int,input().split())
A=list(map(int,input().split()))
for a in A:
if L<=a<=R:
print(a)
elif a<L:
print(L)
else:
print(R)
要素との差が最小の数字、L,R,Ai
####################################
[MY TLE]
N,L,R=map(int,input().split())
A=list(map(int,input().split()))
ANS=[]
for i in range(N):
MIN=10**9
minj=10**9
for j in range(L,R+1):
if MIN>abs(j-A[i]):
MIN=abs(j-A[i])
minj=j
ANS+=[minj]
print(*ANS)
####################################