본문 바로가기

알고리즘/Codeforces19

Codeforces Round #662 (Div. 2) ABC from sys import stdin def input(): return stdin.readline().rstrip() for _ in range(int(input())): n=int(input()) print(1+n//2) A - Rainbow Dash, Fluttershy and Chess Coloring 직접 시뮬레이션 해 보면 1 - 2 - 2 - 3 - 3 - 4 - 4 - ... 순으로 답이 됨을 알 수 있다. #include #include #include #include #include using namespace std; int n, q; map plank; char oper; int target; int main() { ios::sync_with_stdio(0); cin.tie(0);.. 2020. 8. 8.
Codeforces Round #660 (Div. 2) AB from sys import stdin T=int(stdin.readline()) for _ in range(T): n=int(stdin.readline()) if n 2020. 8. 6.
Educational Codeforces Round 92 (Rated for Div. 2) A from sys import stdin from math import gcd def lcm(a, b): return a * b / gcd(a, b) T=int(stdin.readline()) for _ in range(T): l,r=map(int,stdin.readline().split()) if l==1: print(1,2) else: if lcm(l,int(l*(1.5))) 2020. 8. 6.
Codeforces Round #658 (Div. 2) AB from sys import stdin T=int(stdin.readline()) A=[] B=[] for _ in range(T): n,m=map(int,stdin.readline().split()) A=list(map(int,stdin.readline().split())) B=list(map(int,stdin.readline().split())) res=list(set(A) & set(B)) if len(res)==0: print("NO") else: print("YES") print(1,res[0]) A - Common Subsequence from sys import stdin T=int(stdin.readline()) for _ in range(T): cnt=0 N=int(stdin.readli.. 2020. 8. 6.
Codeforces Round #661 (Div. 3) ABC from sys import stdin def input(): return stdin.readline().rstrip() for _ in range(int(input())): n=int(input()) s=sorted(list(map(int,input().split()))) if len(s)==1: print("YES") else: flag=True for i in range(n): if s[i]-s[i-1]>1: flag=False if flag: print("YES") else: print("NO") A - Remove Smallest from sys import stdin def input(): return stdin.readline().rstrip() for _ in range(int(input(.. 2020. 8. 6.
Codeforces Round #656 (Div. 3) ABC #include #include using namespace std; int T, x, y, z; int a[3]; int main() { cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(0); cin >> T; while (T--) { cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if (a[1] != a[2]) { cout a[i - 1]) slope = -1; else if (a[i] a[i - 1.. 2020. 8. 6.