본문 바로가기

div213

Codeforces Round #699 (Div. 2) ABC import sys; input = sys.stdin.readline for TEST in range(int(input())): N, M = map(int, input().split()) res = True cnt = [0 for i in range(4)] for c in input().rstrip(): if c=="R": cnt[0] += 1 if c=="U": cnt[1] += 1 if c=="L": cnt[2] += 1 if c=="D": cnt[3] += 1 if N>=0: if N > cnt[0]: res = False else: if -N > cnt[2]: res = False if M>=0: if M > cnt[1]: res = False else: if -M > cnt[3]: res = F.. 2021. 2. 7.
Educational Codeforces Round 99 (Rated for Div. 2) ABCD import sys input = sys.stdin.readline for TEST in range(int(input())): print(len(input().rstrip())) A - Strange Functions A번에 이렇게 큰 수를 다루는 문제가 나올 리 없기 때문에 당당하게 길이를 출력하였다. #include using namespace std; typedef long long ll; ll dp[2000001]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); set s; for (int i = 1; i TEST; while (TEST--) { int n; cin >> n; cout TEST; while (TEST--) { int.. 2020. 12. 1.
Educational Codeforces Round 98 (Rated for Div. 2) ACD import sys input = sys.stdin.readline for TEST in range(int(input())): n, m = map(int, input().split()) p, q = min(n, m), max(n, m) q -= p print(n+m+max(0, q-1)) A - Robot Program 로봇이 멈추지 않고 최선의 방법으로 가는 방법은 긴 쪽으로 두 칸, 짧은 쪽으로 한 칸 움직이는 것이다. 따라서 위와 같은 방법으로 최대한 멀리 간 다음 두 칸 움직이고 한 칸 쉬는 것이 최선(중 하나)이다. #include using namespace std; typedef pair pii; int main() { ios::sync_with_stdio(0); cin.tie(0); cou.. 2020. 11. 20.
Codeforces Round #684 (Div. 2) ABC1 import sys import collections input = sys.stdin.readline deque = collections.deque for _ in range(int(input())): n, c0, c1, h = map(int, input().split()) s = input().rstrip() zCnt, oCnt = s.count('0'), s.count('1') print(min(c0*zCnt + c1*oCnt, c0*zCnt + c0*oCnt + h*oCnt, c1*oCnt + c1*zCnt + h*zCnt)) A - Buy the String 문자열 중 일부만 바꾸는 것으론 절대 최대 이익을 볼 수 없다. 따라서 0을 모두 1로 바꾸거나, 1을 모두 0으로 바꾸거나, 그대로 구매하.. 2020. 11. 18.
Codeforces Round #683 (Div. 2, by Meet IT) AB import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) print(n) for i in range(n): print(i+1, end=" ") print() A - Add Candies 한 바구니를 선택한다는 조건을 무시하면, 사탕을 n번 넣었을 때 모든 바구니에 똑같이 (n * (n+1))/2 개의 사탕을 넣게 된다. 이때 각 바구니에 들어있는 사탕 수는 처음과 같이 등차 +1의 관계를 가진다. 따라서 1번 바구니부터 1, 2, 3... 순서로 빼주면 모든 바구니가 같은 수의 사탕을 가지게 된다. 결론은 1번부터 n번까지 순서대로 한 번 씩 선택하면 된다. #include using namespace std;.. 2020. 11. 16.
Codeforces Round #669 (Div. 2) ABC from sys import stdin def input(): return stdin.readline().rstrip() for _ in range(int(input())): l = int(input()) s = list(map(int, input().split())) r = [] for i in range(l//2): if s[i*2] == 0 and s[i*2+1] == 0: r.append(0); r.append(0); elif s[i*2] == 1 and s[i*2+1] == 1: r.append(1); r.append(1); else: r.append(0); print(len(r)) print(*r) A - Ahahahahahahahaha 입력의 길이가 반드시 2n이라는 점에 근거하여 두 자리씩.. 2020. 9. 9.