solved.ac: CLASS 2

Introduction

직사각형에서 탈출

https://www.acmicpc.net/problem/1085

import sys
input = sys.stdin.readline

x, y, w, h = map(int,input().split())

print(min(min(x,w-x),min(y,h-y)))

Hashing

https://www.acmicpc.net/problem/15829

50점

import sys
input = sys.stdin.readline

L = int(input())

string = input().rstrip("\n")

r = 31
m = 1234567891

H = 0
for i in range(len(string)):
    H = H + (ord(string[i])-96)*r**i

print(H)

팰린드롬수

import sys
input = sys.stdin.readline

lists = []
string = input().rstrip("\n")
lists.append(string)
while string != '0':
    string = input().rstrip("\n")
    lists.append(string)

lists = lists[:-1]
result = ['']*len(lists)
for i in range(len(lists)):
    result[i] = "yes"
    for j in range(0,len(lists[i])//2):
        if lists[i][j] != lists[i][-j-1]:
            result[i] = "no"
            break

for r in result:
    print(r)

나이순 정렬

https://www.acmicpc.net/problem/10814

나이를 입력받고 intager로 변환하지 않으면 잘못 정렬 될 수 있다.

import sys
input = sys.stdin.readline

N = int(input())

member = {}
age_list = []
for _ in range(N):
    age, name = input().split()
    if age not in member.keys():
        member[age] = [name]
        age_list.append(int(age))
    else:
        member[age].append(name)

age_list.sort()
for a in age_list:
    for m in member[str(a)]:
        print("{} {}".format(a,m))

나무 자르기

https://www.acmicpc.net/problem/2805

시간초과

import sys
input = sys.stdin.readline

N, M = map(int,input().split())
lists = list(map(int,input().split()))

maximum = max(lists)

result = 0
for m in range(maximum-1,-1,-1):
    cut = []
    for l in lists:
        cut.append(max(l-m,0))
    S = sum(cut)
    if S >= M:
        result = m
        break
print(result)

수 정렬하기 3

import sys
input = sys.stdin.readline

K = int(input())
money = []
for _ in range(K):
    number = int(input())
    if number != 0:
        money.append(number)
    else:
        money.pop()
if len(money) == 0:
    print(0)
else:
    print(sum(money))

통계학

https://www.acmicpc.net/problem/2108

from collections import Counter
import sys
input = sys.stdin.readline

N = int(input())

s = 0
numbers = []
catch = {}
for _ in range(N):
    num = int(input())
    s += num
    numbers.append(num)
numbers.sort()

print(round(s/N))
print(numbers[N//2])
nums = Counter(numbers).most_common()
if N > 1:
    if nums[0][1] == nums[1][1]:
        print(nums[1][0])
    else:
        print(nums[0][0])
else:
    print(nums[0][0])
print(numbers[-1]-numbers[0])

설탕 배달

2022

Stack

1 minute read

Introduction

Stack

less than 1 minute read

Introduction

Download-only-one-directory

less than 1 minute read

Git 명령어를 사용한 하위 디렉토리 다운로드 Clone 할 로컬 저장소 생성

Sort

3 minute read

Introduction

Tree

less than 1 minute read

Introduction

Mutex library on C++

less than 1 minute read

#include <iostream> #include <thread> #include <chrono> #include <mutex> #include <atomic> #include <string.h>

TODO

less than 1 minute read

how to costom github blog using jekyll

Welcome to Jekyll!

less than 1 minute read

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different wa...

Back to top ↑