목록Computer/Coding Test (122)
Machineboy空

N의 범위가 1000이하로 매우 작기 때문에 n2^시간 복잡도 알고리즘으로 풀 수 있다. N = int(input()) A = [0] * N for i in range(N): A[i] = int(input()) for i in range(N-1): for j in range(N-1-i): if A[j] > A[j+1]: temp = A[j] A[j] = A[j+1] A[j+1] = temp for i in range(N): print(A[i])

from queue import PriorityQueue import sys print = sys.stdout.write input = sys.stdin.readline N = int(input()) myQueue = PriorityQueue() for i in range(N): request = int(input()) if request == 0: if myQueue.empty(): print('0\n') else: temp = myQueue.get() print(str((temp[1]))+'\n') else: myQueue.put((abs(request),request))

#오답 whole, part = map(int, input().split()) DNA = str(input()) A,C,G,T = map(int, input().split()) Acount = 0 Ccount = 0 Gcount = 0 Tcount = 0 AvailableCount = 0 for i in range(whole-part): k = i + part for k in range(part+k): if DNA[i]=="A": Acount +=1 elif DNA[i]=="C": Ccount +=1 elif DNA[i]=="G": Gcount +=1 elif DNA[i]=="T": Tcount +=1 if Acount >= A and Ccount >=C and Gcount >=G and Tcount >..

n = int(input()) count = 1 start_index = 1 end_index = 1 sum = 1 while end_index !=n: if sum == n: count +=1 end_index +=1 sum += end_index elif sum >n: sum -= start_index start_index +=1 else: end_index +=1 sum += end_index print(count) 오답 이유) 이런 똑똑한 알고리즘이 있다니
문제설명 머쓱이는 태어난 지 6개월 된 조카를 돌보고 있습니다. 조카는 아직 "aya", "ye", "woo", "ma" 네 가지 발음을 최대 한 번씩 사용해 조합한(이어 붙인) 발음밖에 하지 못합니다. 문자열 배열 babbling이 매개변수로 주어질 때, 머쓱이의 조카가 발음할 수 있는 단어의 개수를 return하도록 solution 함수를 완성해주세요. 제한사항 1
using System; using System.Collections.Generic; namespace CodingTestForBaekJoon { class Program { static void Main(string[] args) { //1: 시험 본 과목 개수 N //2. 현재 성적 (N개의 성적 중 최댓값 M) int N = int.Parse(Console.ReadLine()); string[] scores = Console.ReadLine().Split(); float[] scoreNum = new float[N]; for(int i = 0; i < scores.Length; i++) { scoreNum[i] = float.Parse(scores[i]); } //최댓값 구하기 float M = 0..
private void UpdateSearch() { // Scene에 배치된 타워들을 모두 찾아서 GameObject[] towers = GameObject.FindGameObjectsWithTag("Tower"); // 최단거리, 선택배열번호 float distance = float.MaxValue; int chooseIndex = -1;//index로 들어갈 수 없는 -1을 넣는다. for (int i = 0; i < towers.Length; i++) { // 타워와 나와의 거리를 재고 float temp = Vector3.Distance(towers[i].transform.position, transform.position); // 그 거리가 최단거리보다 작다면 if (temp < distanc..
using System;using System.Text;namespace CodingTestForBaekJoon{ class Program { static void Main(string[] args) { while (true) { string input = Console.ReadLine(); if (input == null) { break; } string[] cases = input.Split(); int a = int.Parse(cas..