코테 대비 python/백준
-
14503 로봇 청소기코테 대비 python/백준 2023. 4. 11. 00:48
https://www.acmicpc.net/problem/14503 14503번: 로봇 청소기 첫째 줄에 방의 크기 $N$과 $M$이 입력된다. $(3 \le N, M \le 50)$ 둘째 줄에 처음에 로봇 청소기가 있는 칸의 좌표 $(r, c)$와 처음에 로봇 청소기가 바라보는 방향 $d$가 입력된다. $d$가 $0$인 경우 북쪽 www.acmicpc.net n,m = map(int,input().split()) r,c,d = map(int,input().split()) graph = [list(map(int,input().split())) for _ in range(n)] visited = [[0]*m for _ in range(n)] #처음 빈칸은 전부 청소되지 않은 상태이다. #순서대로 구현하자!..
-
1966 프린터 큐코테 대비 python/백준 2023. 4. 10. 22:59
https://www.acmicpc.net/problem/1966 1966번: 프린터 큐 여러분도 알다시피 여러분의 프린터 기기는 여러분이 인쇄하고자 하는 문서를 인쇄 명령을 받은 ‘순서대로’, 즉 먼저 요청된 것을 먼저 인쇄한다. 여러 개의 문서가 쌓인다면 Queue 자료구조에 www.acmicpc.net from collections import deque T=int(input()) for _ in range(T): n,m = map(int,input().split()) w = list(map(int,input().split())) que=[0]*n index=[0]*n cnt=0 #순서와 가중치 저장 for i in range(len(w)): que[i] = w[i] index[i] = i #pop..
-
13335 트럭코테 대비 python/백준 2023. 4. 10. 11:45
https://www.acmicpc.net/problem/13335 13335번: 트럭 입력 데이터는 표준입력을 사용한다. 입력은 두 줄로 이루어진다. 입력의 첫 번째 줄에는 세 개의 정수 n (1 ≤ n ≤ 1,000) , w (1 ≤ w ≤ 100) and L (10 ≤ L ≤ 1,000)이 주어지는데, n은 다리를 건너는 트 www.acmicpc.net ##다른분의 코드 n, w, l = map(int, input().split()) trucks = list(map(int, input().split())) bridge = [0] * w time = 0 #핵심은 들어갈게 없다면 0을 어팬드하는것 while bridge: time += 1 bridge.pop(0) #트럭에 있다면 if trucks: i..
-
14888 연산자 끼워넣기코테 대비 python/백준 2023. 4. 4. 22:42
https://www.acmicpc.net/problem/14888 14888번: 연산자 끼워넣기 첫째 줄에 수의 개수 N(2 ≤ N ≤ 11)가 주어진다. 둘째 줄에는 A1, A2, ..., AN이 주어진다. (1 ≤ Ai ≤ 100) 셋째 줄에는 합이 N-1인 4개의 정수가 주어지는데, 차례대로 덧셈(+)의 개수, 뺄셈(-)의 개수, www.acmicpc.net #수의 개수 n = int(input()) #수열 A = list(map(int, input().split())) plus,minus,multi,divide = map(int,input().split()) # 그냥 다 더한다음에 result에 어팬드하고, max랑 min 출력 result = [] #result_max,result_min = ..
-
13458 시험감독코테 대비 python/백준 2023. 3. 29. 21:47
https://www.acmicpc.net/problem/13458 13458번: 시험 감독 첫째 줄에 시험장의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 각 시험장에 있는 응시자의 수 Ai (1 ≤ Ai ≤ 1,000,000)가 주어진다. 셋째 줄에는 B와 C가 주어진다. (1 ≤ B, C ≤ 1,000,000) www.acmicpc.net n = int(input()) a = map(int,input().split()) b, c = map(int,input().split()) num =0 for i in a: if (i-b) >=0: if (i - b)%c ==0: num+=(i-b)//c else: num+=((i-b)//c +1) print(n+num)
-
2670 연속부분최대곱코테 대비 python/백준 2023. 3. 29. 21:17
https://www.acmicpc.net/problem/2670 2670번: 연속부분최대곱 첫째 줄은 나열된 양의 실수들의 개수 N이 주어지고, 그 다음 줄부터 N개의 수가 한 줄에 하나씩 들어 있다. N은 10,000 이하의 자연수이다. 실수는 소수점 첫째자리까지 주어지며, 0.0보다 크거나 www.acmicpc.net n = int(input()) num = [] for _ in range(n): num.append(float(input())) for i in range(1,n): num[i] = max(num[i-1]*num[i],num[i]) #print(num) print(f"{max(num):.3f}")
-
9372 상근이의 여행코테 대비 python/백준 2023. 3. 24. 23:46
https://www.acmicpc.net/problem/9372 9372번: 상근이의 여행 첫 번째 줄에는 테스트 케이스의 수 T(T ≤ 100)가 주어지고, 각 테스트 케이스마다 다음과 같은 정보가 주어진다. 첫 번째 줄에는 국가의 수 N(2 ≤ N ≤ 1 000)과 비행기의 종류 M(1 ≤ M ≤ 10 000) 가 www.acmicpc.net #상근이의 자아 찾기 #가장 적은 종류의 비행기를 타고 모든 국가들을 여행 #상근이가 한 국가에서 다른 국가로 이동할 때 다른 국가를 거쳐가도 된다 #맨처음은 bfs? dfs? 라고 생각했는데 모든 국가가 연결되어있으므로 사실 비행기는 국가-1일 수 밖에 없다. import sys input = sys.stdin.readline t= int(input()) f..
-
2217 로프코테 대비 python/백준 2023. 3. 23. 11:39
https://www.acmicpc.net/problem/2217 2217번: 로프 N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하 www.acmicpc.net #시간 제한 2초 메모리제한도 192mb로 넉넉한 편 import sys input = sys.stdin.readline n = int(input()) w = [int(input()) for _ in range(n)] #print(min(w)*n) #n빵한다음에 최대 버틸수 있는 중량 체크 #모든 로프를 사용해야 할 필요는 없으며, 임의로 몇 개의 로프를 골라서 사용해도 된다. #w/k ..