목록전체 글 (251)
정화 코딩

https://www.acmicpc.net/problem/15889 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector loc = vector(n); vector avl = vector(n - 1); for (int i = 0; i > loc[i]; } for (int i = 0; i > avl[i]; } if (n == 1) { cout 0; i--) { if (loc[i] + avl[i] >= nxt) { ..

https://www.acmicpc.net/problem/17386 #pythonimport sysinput = sys.stdin.readlinex1, y1, x2, y2 = map(int, input().split())x3, y3, x4, y4 = map(int, input().split())def ccw(x1, y1, x2, y2, x3, y3): ccw = (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 * y2 + x1 * y3) if ccw > 0: return 1 elif ccw ccw의 결과값을 통해 세 점의 위치 관계를 파악할 수 있다.ccw = (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 ..

12-1. 기하 알아보기 097. CCW (백준 11758번) https://www.acmicpc.net/problem/11758 import sysinput = sys.stdin.readlinex1, y1 = map(int, input().split())x2, y2 = map(int, input().split())x3, y3 = map(int, input().split())ccw = (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 * y2 + x1 * y3)if ccw > 0: print(1)elif ccw ccw의 결과값을 통해 세 점의 위치 관계를 파악할 수 있다. ccw = (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 ..

AtCoder Beginner Contest 355 (https://atcoder.jp/contests/abc355) A . Who Ate the Cake? https://atcoder.jp/contests/abc355/tasks/abc355_a //C++#include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector p = vector(4, true); for (int i = 0; i > x; p[x] = false; } int cnt = 0; int ans; for (int i = 1; i (정답) B..

#include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector> data (n); vector ans = vector(n); for (int i = 0; i > data[i].first; data[i].second = i; } sort(data.begin(), data.end()); int cnt = 0; int tmp = 0; ans[data[0].second] = 0; int pre = data[0].first; for (in..

https://www.acmicpc.net/problem/1074 #include #include #include using namespace std;int cnt = 0;vector> m;void search(int sx, int sy, int size) { if (size == 1) { m[sy][sx] = cnt++; return; } int div = size / 2; search(sx, sy, div); search(sx + div, sy, div); search(sx, sy + div, div); search(sx + div, sy + div, div);}int main() { ios_base::sync_with_stdio(0..

A. 악수 (백준 8394번) https://www.acmicpc.net/problem/8394 //C++#include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector dp = vector(n + 1); dp[0] = 0; dp[1] = 1; if (n >= 2) { dp[2] = 2; } for (int i = 3; i (정답) B. 가장 큰 감소하는 부분 수열 (백준 17216번) https://www.acmicpc.net/problem/17216 //C..

공유기 설치 (백준 2110번) https://www.acmicpc.net/problem/2110문제 해석문제에서 주어진 예제를 그려보면 이렇게 된다. 1, 2, 4, 8, 9 위치에 집이 배치되어 있다. 이런 상황에서 가장 인접한 두 공유기 사이의 최대 거리는 공유기를 1, 4, 8에 설치하는 경우와 1, 4, 9에 설치하는 경우 모두 3이 된다. 이런 답은 어떤 과정으로 나오는 것일까? 우선 이 문제를 코드로 해결하는 게 아닌 인간인 우리가 푼다고 생각해보자. '대충 간격을 4 이상으로 둬볼까? 아 4이상으로 하니까 공유기가 남네... 그러면 좀 더촘촘히 둬도 될 것 같으니까 간격을 더 늘려서.....' 이런식으로 푸는 것이 자연스러워 보인다. 이런 경우에 사용되는 알고리즘이 이분 탐색이다.풀이//C..