코딩테스트
-
08/19 코딩테스트 백준 1541 잃어버린 괄호코딩테스트 2021. 8. 19. 19:36
https://www.acmicpc.net/problem/1541 1541번: 잃어버린 괄호 첫째 줄에 식이 주어진다. 식은 ‘0’~‘9’, ‘+’, 그리고 ‘-’만으로 이루어져 있고, 가장 처음과 마지막 문자는 숫자이다. 그리고 연속해서 두 개 이상의 연산자가 나타나지 않고, 5자리보다 www.acmicpc.net txt = input() arr = txt.split('-') arr2 = [] for x in range(len(arr)): arr2.append(eval(arr[x])) tmp = arr2[0] for x in range(len(arr2)): if(x+1 < len(arr2)): tmp -= arr2[x+1] print(tmp) 출력은 제시한 대로 잘 되는거 같은데 런타임 에러가 뜬다
-
08/19 백준 코딩테스트 1931 회의실 배정코딩테스트 2021. 8. 19. 18:59
https://www.acmicpc.net/problem/1931 1931번: 회의실 배정 (1,4), (5,7), (8,11), (12,14) 를 이용할 수 있다. www.acmicpc.net count = int(input()) arr = [] for x in range(count): (i, j) = map(int, input().split()) arr.append((i, j)) arr.sort() tmp = 0 n = 0 for x in range(count): if(arr[x][0] > tmp): tmp = arr[x][1] n += 1 continue print(n) 일단 값은 제대로 나오는데 틀렸다고 나온다 처음에는 잘 이해가 가지 않아서 다른 사람 코드를 보고 힌트를 얻었다
-
08/18 백준 코딩테스트 11047 동전 0코딩테스트 2021. 8. 18. 17:26
import math txt = input() params = txt.split() coins = [] for x in range(int(params[0])): coins.append(input()) coins.reverse() countCoin = 0 tmp = int(params[1]) for x in coins: tmpCoin = math.trunc(tmp / int(x)) countCoin += tmpCoin tmp -= int(x) * tmpCoin print(countCoin) 파이썬을 새로 공부하고 첫 코딩테스트를 해보는거라 오래걸렸다
-
06/02 백준 코딩테스트 11399 ATM코딩테스트 2021. 6. 2. 23:31
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { List vs = new List(); int n = int.Parse(Console.ReadLine()); string input = Console.ReadLine(); string[] p = input.Split(' '); Array.Sort(p); for (int i = 0; i
-
06/02 백준 코딩테스트 2839 설탕 배달코딩테스트 2021. 6. 2. 01:26
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int tmp = n / 5; int count5kg; int count3kg; bool bol = true; for (int i = tmp; i >= 0; i--) { count5kg = i; int a = n - (5 * count5kg); count3kg = a / 3; int b = count5..