๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ๐Ÿฃ: ๐’œ๐“๐‘”๐‘œ๐“‡๐’พ๐“‰๐’ฝ๐“‚

(34)
BOJ9095 : 1, 2, 3 ๋”ํ•˜๊ธฐ (Silver 3) ๋„ˆ๋ฌด ์˜ค๋žœ๋งŒ์— DP ํ’€์—ˆ๋”๋‹ˆ ์–ด์ผ€ํ•˜๋Š”๊ฑด์ง€ ์™„์ „ ๊นŒ๋จน์—ˆ๋Š”๋ฐ ์ธํ„ฐ๋„ท์— ์น˜์ž๋งˆ์ž ๋– ์˜ค๋ฆ„ DP == ์ ํ™”์‹ ์„ธ์šฐ๊ธฐ ๊ทธ๋ž˜์„œ DP ๊ธฐ๋ณธ ๋ฌธ์ œ๋Š” ์ฝ”๋”ฉ๋ณด๋‹ค๋Š” ์ˆ˜ํ•™๋ฌธ์ œ ํ‘ธ๋Š” ๊ฒƒ ๊ฐ™์€ ๋Š๋‚Œ์ด ๋“ ๋‹ค.. ์ฒ˜์Œ์— ์ด์ƒํ•œ ์ง“ํ•˜๋‹ค๊ฐ€ ์ธํ„ฐ๋„ท์˜ ํž˜์„ ๋นŒ๋ ค ํžŒํŠธ๋ฅผ ์–ป์—ˆ๊ณ , ๊ทธ ๋‹ต์€ dp[i] = dp[i-3] + dp[i-2] + dp[i-1] ์˜ˆ๋กœ, a5๋ฅผ ๊ตฌํ•œ๋‹ค๊ณ  ํ•ด๋ณด๋ฉด a4 ์ฆ‰ 4๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์— ์ „๋ถ€ +1 ํ•œ ๊ฒƒ + a3 ์ฆ‰ 3์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์— ์ „๋ถ€ +2 ํ•œ ๊ฒƒ + a2 ์ฆ‰ 2๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์— ์ „๋ถ€ +3 ํ•œ ๊ฒƒ ์ด ๋ฐ”๋กœ 5๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์˜ ์ „๋ถ€์ด๋‹ค. (2) + 3 (3) + 2 (4) + 1 ๊ด„ํ˜ธ ์•ˆ์˜ ์ˆ˜๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐฉ๋ฒ•์€ ์ด๋ฏธ ์•ž์—์„œ ๊ตฌํ•ด๋†จ์œผ๋‹ˆ, ๊ทธ ๋ฐฉ๋ฒ•์—๋‹ค๊ฐ€ ๊ฐ๊ฐ 3, 2, 1์„ ๋”ํ•˜๋ฉด ๋จ #include int dp[12]..
BOJ2468 : ์•ˆ์ „์˜์—ญ (Silver 1) ์šฐ์„  ๋‚˜๋Š” make_safezone์œผ๋กœ safe_zone ๋ฐฐ์—ด์— ์นจ์ˆ˜๋˜๋Š”์ง€ ์•„๋‹Œ์ง€๋ฅผ ์ €์žฅํ•ด์ฃผ์—ˆ๋‹ค. rain_height๋ณด๋‹ค ๋†’์ด๊ฐ€ ๋†’์œผ๋ฉด 1, ๋‚ฎ๊ฑฐ๋‚˜ ๊ฐ™์œผ๋ฉด 0์œผ๋กœ ์˜์—ญ์ด 1๋กœ ๊ฐ€์‹œ์ ์œผ๋กœ ๋ณด์ด๊ฒŒ ๋งŒ๋“ค์–ด์คŒ ๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ count_safezone ํ•ด์„œ ๋งŒ๋“ค์–ด ๋‘” safezone์˜ ์˜์—ญ ํฌ๊ธฐ๋ฅผ DFS๋ฅผ ํ™œ์šฉํ•ด ์„ธ์–ด์ฃผ์—ˆ๋‹ค. ์ด ๊ณผ์ •์„ rainheight 0๋ถ€ํ„ฐ 100๊นŒ์ง€ ๋ฐ˜๋ณตํ•ด ์ตœ๋Œ“๊ฐ’์„ ์ฐพ์•„์ฃผ๋ฉด ๋! #include #include #include using namespace std; int height[100][100] = {0,}; int safe_zone[100][100] = {0,}; int N = 0; void make_safezone(int rain_height); int count_safezone(..
BOJ3184 : ์–‘ (Silver 1) https://www.acmicpc.net/problem/3184 ์˜ค๋žœ๋งŒ์— ๋Œ์•„์˜จ PS~~~^~^ ์—ฌ๋Ÿฌ๋ถ„ ํ˜น์‹œ ํ•œ ๋ฒˆ์— ๋งž์€ ๊ธฐ๋ถ„์ด ์–ด๋–ค์ง€ ์•„์‹œ๋‚˜์š” ์ผ๋‹จ ์ €๋Š” ์••๋‹ˆ๋‹ค ใ…Žํžˆํžˆใ…ฃํžˆํžˆ ์ง€๊ธˆ ๋‹น์—ฐํžˆ ๋ญํ•˜๋‚˜ ์˜ˆ์™ธ ์žˆ๊ฒ ์ง€ ํ•˜๊ณ  ๋ƒ…๋‹ค ๋Œ๋ ค๋ดค๋Š”๋ฐ ๊ฐ‘์ž๊ธฐ 100% ๋œจ๊ณ  ๋งž์•˜์Šต๋‹ˆ๋‹ค ๋– ์„œ ์†Œ๋ฆฌ์ง€๋ฅผ๋ป”ํ•จ ์ •๋ง ์˜ค๋žœ๋งŒ์— ๋ฐฑ์ค€ ๋‹ค์‹œ ํ’€๊ณ  ์žˆ๋Š”๋ฐ ์–ด์งธ์„œ์ธ์ง€ ํ•œ์ฐธ ๊ณต๋ถ€ํ•  ๋•Œ๋ณด๋‹ค ๋จธ๋ฆฌ๊ฐ€ ๋” ํŒฝํŒฝ ์ž˜ ๋Œ์•„๊ฐ€์œ ,,, ์˜›๋‚ ์—” ์‹ค๋ฒ„ 1 ์ด๋ ‡๊ฒŒ ๋นจ๋ฆฌ ๋ชป ํ’€์—ˆ์—ˆ๋Š”๋ฐ... ๊ทธ๋Ÿผ ์„ค๋ช…์„ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹น 1. ์šฐ์„  ๊ธฐํ˜ธ๋ฅผ ์ „๋ถ€ ์ˆซ์ž๋กœ ๋ฐ”๊ฟ” ์ด์ฐจ์› ๋ฐฐ์—ด map์— ์ €์žฅํ•ด์ค€๋‹ค ๋ณด์ž๋งˆ์ž ์™œ์ธ์ง€ ๊ธฐํ˜ธ ๊ทธ๋Œ€๋กœ ๋ƒ…๋‘๋ฉด ๋‚ด๊ฐ€ ๋„ˆ๋ฌด ํ—ท๊ฐˆ๋ฆด ๊ฒƒ ๊ฐ™์•„์„œ ๊ทธ๋ƒฅ ์‹น ๋‹ค ์ˆซ์ž๋กœ ๋ณ€ํ˜•ํ•ด์„œ ์ €์žฅํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค ์‚ฌ์‹ค ๋ญ ์‹คํ–‰ ์†๋„์— ์—„์ฒญ ํฐ ์ œ์•ฝ์ด ์žˆ๋Š” ๊ทธ๋Ÿฐ ๋ฌธ์ œ์˜€์œผ๋ฉด ๊ตณ์ด ์•ˆํ•˜๋Š”๊ฒŒ ๋” ..
BOJ5671 : ํ˜ธํ…” ๋ฐฉ ๋ฒˆํ˜ธ (Silver 5) #include using namespace std; int main() { while (1) { int N, M; int count = 0; cin >> N >> M; if (cin.eof()) break; for (int i = N; i
BOJ14889 : ์Šคํƒ€ํŠธ์™€ ๋งํฌ (Silver 3) #include using namespace std; int N; int map[21][21]; int ans = 100000000; bool is_visited[21]; void DFS(int player, int cnt) { if (cnt == N / 2) { int score1 = 0; int score2 = 0; for (int i = 1; i
BOJ 2503 : ์ˆซ์ž์•ผ๊ตฌ (Silver 5) #include #include using namespace std; int number; int strike, ball; vector array; void Filtering(int num, int s, int b) { vector newarray; vector::iterator iter; int strike = 0, ball = 0; for (iter = array.begin(); iter != array.end(); iter++) { int strike = 0, ball = 0; // cout
BOJ17404 : RGB๊ฑฐ๋ฆฌ2 (Gold 4) #include using namespace std; int cost[1000][3]; long long costDP[1000][3]; long long result[3]; //long long result = 1000 * 10000 + 1; void makeDP(int N) { for (int j = 0; j < 3; j++) { costDP[0][0] = 1000 * 10000 + 1; costDP[0][1] = 1000 * 10000 + 1; costDP[0][2] = 1000 * 10000 + 1; costDP[0][j] = cost[0][j]; for (int i = 1; i < N; i++) { costDP[i][0] = min(costDP[i - 1][1], costDP[i - 1][2]) ..
BOJ1149 : RGB๊ฑฐ๋ฆฌ (Silver 1) #include using namespace std; int cost[1000][3]; long long costDP[1000][2]; void makeDP(int N) { costDP[0][0] = cost[0][0]; costDP[0][1] = cost[0][1]; costDP[0][2] = cost[0][2]; for (int i = 1; i < N; i++) { costDP[i][0] = min(costDP[i - 1][1], costDP[i - 1][2]) + cost[i][0]; costDP[i][1] = min(costDP[i - 1][0], costDP[i - 1][2]) + cost[i][1]; costDP[i][2] = min(costDP[i - 1][0], costDP[i - 1][1..
BOJ11660 : ๊ตฌ๊ฐ„ ํ•ฉ ๊ตฌํ•˜๊ธฐ 5 (Silver 1) #include using namespace std; int map[1025][1025]; long long sum[1025][1025]; void sumMaker(int N) { for (int i = 0; i > M; int x1, x2, y1, y2; for (int i = 1; i map[i][j]; } } sumMaker(N); for (int i = 0; i > x1 >> y1 >> x2 >> y2; cout
BOJ2012 : ๋“ฑ์ˆ˜๋งค๊ธฐ๊ธฐ (Silver 3) #include #include using namespace std; int N; int prerank[500001]; long long rankingSystem() { long long angry = 0; for (int i = 1; i > N; for (int i = 1; i > prerank[i]; } sort(prerank + 1, prerank + N + 1); cout