Codeforce
-
Codeforces Round #524 (Div. 2) - A. Petya and Origami코드포스(CodeForce) 2020. 1. 20. 14:55
http://codeforces.com/contest/1080/problem/A Problem - A - Codeforces codeforces.com 1. 문제 페티아는 그녀의 저녁 파티에 n 명을 초대 하려고 한다. 초대장은 2개의 빨간 종이, 5개의 초록 종이, 8개의 파란색 종이가 필요하다. 페티아는 초대장을 만들기 위해서 상점에 갔다. 상점에서는 오직 하나의 색상의 색종이를 k개의 묶음으로 판매 한다. n 명에 초대장을 만들기 위해 페티아가 구매할 색종이의 최소 개수를 구하여라. 2. 알고리즘 키워드 - 구현 3. 코드 #include #include #include #include #include #include #include #include #include #include #include ..
-
Codeforces Round #462 (Div. 2) - A. A Compatible Pair코드포스(CodeForce) 2018. 8. 17. 18:30
1. 문제 2. 알고리즘키워드 - 구현 * 최노키오 소견 FACT - 음수 곱하기 음수는 양수가 된다. 3. 코드 1234567891011121314151617181920212223242526272829303132333435363738#include#include#include#include#include using namespace std; long long INF = 1ull n >> m; vector arr(n), brr(m); for (int i = 0; i > arr[i]; for (int i = 0; i > brr[i]; long long tmp = -INF; int selIdx = -1; for (int i = 0; i
-
Educational Codeforces Round 38 (Rated for Div. 2) - Word Correction코드포스(CodeForce) 2018. 8. 17. 18:29
1. 문제 2. 알고리즘키워드 - 구현 문제에 제약 사항을 정확히 파악 해야한다.In this problem letters a, e, i, o, u and y are considered to be vowels. 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#include#include#include#include#include#include using namespace std; bool isMoum(char ch) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y') { return tru..
-
Educational Codeforces Round 38 (Rated for Div. 2) - Run For Your Prize코드포스(CodeForce) 2018. 8. 17. 18:28
1. 문제 2. 알고리즘키워드 - 구현 * 접근 방법 왼쪽에서 시작 하면서 현재 위치에서 도착지점까지 거리를 구한다.오른쪽에서 시작하면서 처음 위치까지 거리를 구한다.왼쪽, 오른쪽에 값에서 최소값을 구한다.구한 최소값으로 합계를 구하고, 합계는 최대 값으로 업데이트 한다. 3. 코드 123456789101112131415161718192021222324252627282930313233343536#include#include#include#include#include#include using namespace std; int main(){ int n; cin >> n; vector arr(n); for (int i = 0; i > arr[i]; int sumLeft = 0; int sumLight = 0;..
-
Educational Codeforces Round 37 (Rated for Div. 2) - A. Water The Garden코드포스(CodeForce) 2018. 8. 17. 18:27
1. 문제 2. 알고리즘키워드 - 구현 * 최노키오 소견 재훈씨 map을 선택한거는 아주 좋은 생각이에요.다만 map을 이터레이터를 사용하지 않고 직접 인덱스로 접근 하려고 하면. 만약 map 에 크기가 4 이고map[5] 접근 하는 순간에map 사이즈는 5로 증가가 됩니다. 항상 map 을 사용할 때는 이터레이터로 순회 하거나find 혹은 count 함수로 접근 하도록 하세요. 누구나 처음에 map 을 사용하면서 실수를 하는 문제 입니다. 3. 코드 123456789101112131415161718192021222324252627282930313233343536373839#include#include #include#include using namespace std; int n, k;int a[250]..
-
Educational Codeforces Round 36 (Rated for Div. 2) - A. Garden코드포스(CodeForce) 2018. 8. 17. 18:25
1. 문제 2. 알고리즘키워드 - 구현 * 최노키오 소견 재훈씨 뇌가 말랑 말랑 해지고 좋지 않습니까? 순수하게 완전 탐색으로 풀려고 하는 순수한 코딩 이었습니다. 순수하게 완전탐색으로 풀었군요 호호호. 3. 코드 1234567891011121314151617181920212223242526272829#include#include #include#include#include using namespace std; int main(){ int buckets, dist; cin >> buckets >> dist; vector arr(buckets); for (int i = 0; i > arr[i]; int result = 100000; for (int i = 0; i
-
Educational Codeforces Round 36 (Rated for Div. 2) - B. Browser코드포스(CodeForce) 2018. 8. 17. 18:23
1. 문제 2. 알고리즘키워드 - 구현 * 최노키오 소견 재훈씨문제를 한번에 풀라고 생각하지 말고불변식을 만들어서 하세요. 문제에 제약사항(불변식)을 두어서 풀기 간단하게 만들자.ex) if문 분기로 한번에 최적해를 구하려고 하면 if문들에 의해 많은 난해함이 생긴다. -> if문을 줄일 방법은 무엇인가? 3. 코드 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include#include #include#include#include using namespace std; int main(){ int n, pos, left, right; cin >> n >> pos >> left >> right;..
-
Educational Codeforces Round 35 (Rated for Div. 2) - A.Nearest Minimums코드포스(CodeForce) 2018. 8. 17. 18:22
1. 문제 2. 알고리즘키워드 - 구현 * 문제 분석 입력 받은 숫자 데이터에서 가장 작은 최소값의 사이 거리를 구하는 문제문제 제약 사항It is guaranteed that in the array a minimum occurs at least two times.가장 작은 수는 두개가 있다고 보장 함. * 문제 풀이 입력 받은 데이터가 [4 5 4 1 2 3 4 3 1 5 1] 라면 첫 번째로 입력 받은 데이터 중 가장 작은 원소를 찾는다. 4 5 4 1 2 3 4 3 1 5 1 -> 가장 작은 수는 [1] 두 번째로 가작 작은 수의 사이 거리를 구한다.4 5 4 1 2 3 4 3 1 5 1 -> 사이 거리는 54 5 4 1 2 3 4 3 1 5 1 -> 사이 거리는 2 가장 작은 사이 거리를 구한다...