목록PS/Python (269)
지나가던 개발자

그저 단순한 정렬 문제인 것 같다. members = [] for i in range(int(input())): members.append(input().split()) age = [] for m in members: age.append(int(m[0])) age = sorted(age) for i in range(len(age)): j = 0 while True: if members[j][0] == str(age[i]): break j += 1 print(age[i], members[j][1]) del members[j] 이렇게 짜니 시간 초과가 떴다. 하긴 N이 100000까지인데 100000짜리가 들어온다면 반복문을 엄청나게 돌려야 하니... 그래서 이번에는 다른 블로그를 참고해서 이렇게 코드를 짜..

print(max([sum(list(map(int, input().split()))), sum(list(map(int, input().split())))])) 와.. 대한, 민국, 만세라니... 진짜 오랜만에 듣는 이름이다. 옛날에 초등학교 저학년때 를 처음 했었는데, 그때 기억나는 애들이 대한, 민국, 만세, 그리고 사랑이. 이렇게 기억난다(이제 보니 이름 특이한 애들만 기억나는것 같다.). 이때는 가 진짜 재밌었는데, 최근에 보니까 모르는 애들만 나오고 좀 가식적이게 된 것 같아서 별로...

test_data = [] for i in range(int(input())): test_data.append(list(map(int, input().split()))) for i in range(len(test_data)): test_data[i] = [x for x in test_data[i] if x%2==0] print(sum(test_data[i]), min(test_data[i]))

people = list(map(int, input().split())) people = people[0] * people[1] newspapers = list(map(int, input().split())) for a in newspapers: print(a - people) P㎡인 공간에서 1㎡ 당 사람이 L 명 왔으니 전체 온 사람 수는 P*L 명이 된다.

n = int(input()) hihi = [] while True: a = int(input()) if a == 0: break hihi.append(a) for hi in hihi: if hi % n == 0: print(str(hi) + " is a multiple of " + str(n) + ".") continue print(str(hi) + " is NOT a multiple of " + str(n) + ".")

day = input() cars = input().split() print(cars.count(day)) 리스트에서 특정 요소의 개수를 구하는 법은 저번에 다뤘었다. https://developer-next-to-you.tistory.com/33 [Python] 리스트에서 특정 요소 개수 구하기 살다 보면, 가끔 리스트에서 특정 요소의 개수를 구하는 것이 필요할 때도 있고 하다. examples = [1, 1, 0, 0, 1, 0, 1] zeros = 0 for example in examples: if example == 0: zeros += 1 이렇게 코드를 작.. developer-next-to-you.tistory.com

a, b, c = list(map(int, input().split())) hihi = int(a*b/c) haha = int(a/b*c) if hihi > haha: print(hihi) else: print(haha) 곱하기나 나누기가 들어갈 수 있는 공간은 2개뿐이니 a*b/c와 a/b*c를 계산한 값 중 큰 값을 출력하면 된다.