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

๐Ÿ“ ์•Œ๊ณ ๋ฆฌ์ฆ˜

(139)
[C++/BOJ] 2493 : ํƒ‘ (Stack) https://www.acmicpc.net/problem/2493 ๋ฐฑ์ค€ ๊ณจ๋“œ5์‰ฝ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด์„œ 2์ค‘๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ์ผ๋Š”๋ฐ.. ์‹œ๊ฐ„์ดˆ๊ณผ ใ…‹ใ…‹์Šคํƒ์„ ์‚ฌ์šฉํ•ด์„œ ๋‚ฎ์€ ๊ฑด popํ•˜๊ณ , ์ˆ˜์‹  ํƒ‘๋งŒ ๋‚จ๊ฒจ๋‘์–ด์•ผ ํ•œ๋‹ค  ๋‚˜์˜ ํ’€์ด#include#include#include using namespace std;int main() // ์ด์ค‘๋ฐ˜๋ณต๋ฌธ ์“ฐ๋ฉด ์‹œ๊ฐ„์ดˆ๊ณผ๋‚จ{ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; int height; stack> st; // ์ธ๋ฑ์Šค, ๋†’์ด cin >> n; for (int i = 1; i > height; while(!st.empty()){ if(st.top().second
[C++/BOJ] 11660 : ๊ตฌ๊ฐ„ ํ•ฉ ๊ตฌํ•˜๊ธฐ 5 (DP) https://www.acmicpc.net/problem/11660  ๋ฐฑ์ค€ ์‹ค๋ฒ„1๊ทธ๋ƒฅ ํ’€์—ˆ๋‹ค๊ฐ€ ์‹œ๊ฐ„์ดˆ๊ณผ๋‚˜๊ธธ๋ž˜ ๋ญ์ง€ ์‹ถ์—ˆ๋Š”๋ฐ.. dp ๋ฌธ์ œ์˜€๋‹ค ใ…œใ…œindex 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋ฉด ์ด๊ฒƒ์ €๊ฒƒ ๊ท€์ฐฎ๊ธฐ ๋•Œ๋ฌธ์— index 1๋ถ€ํ„ฐ ์ž…๋ ฅ์„ ๋ฐ›์œผ๋ฉด ํŽธํ•˜๋‹ค  ๋‚˜์˜ ํ’€์ด#include#includeusing namespace std;int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; int m; int num; int dp[1025][1025] = {0,}; int x1; int x2; int y1; int y2; cin >> n >> m; for (int i = 1; i > num; dp[i][j] = dp[i - 1][j] + dp[i..
[C++/SWEA] 1208. [S/W ๋ฌธ์ œํ•ด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - Flatten (D3) https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV139KOaABgCFAYh&categoryId=AV139KOaABgCFAYh&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=CCPP&select-1=3&pageSize=10&pageIndex=1 SW Expert AcademySW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!swexpertacademy.com ezswea๋Š” ๋‚œ์ด๋„๊ฐ€ ๋“ค์‘ฅ๋‚ ์‘ฅ์ด๋ผ๋”๋‹ˆ ๋งž๋Š” ๋ง์ธ ๊ฒƒ ๊ฐ™๋‹ค์ด ๋ฌธ์ œ๋Š” D2๋ณด๋‹ค ์‰ฌ์šด๋“ฏ ๋‚˜์˜ ํ’€์ด#include#include#inc..
[C++/SWEA] 1859. ๋ฐฑ๋งŒ ์žฅ์ž ํ”„๋กœ์ ํŠธ (D2) https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV5LrsUaDxcDFAXc&categoryId=AV5LrsUaDxcDFAXc&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=CCPP&select-1=3&pageSize=10&pageIndex=1 SW Expert AcademySW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!swexpertacademy.com ์•„๋งˆ ๊ทธ๋ฆฌ๋””? ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™๋‹ค๋ฐฐ์—ด์„ ์—ญ์ˆœ์œผ๋กœ ํƒ์ƒ‰ํ•˜๋ฉด์„œ max๊ฐ’์„ ๊ฐฑ์‹ ํ•˜๊ณ , ๊ทธ๋ณด๋‹ค ์ž‘์€ ๊ฐ’๋“ค์€ ๋นผ์ฃผ๋ฉด ๋œ๋‹ค (ํŒ๋งค ํ›„ ์ฐจ์ต..
[C++/SWEA] 21425. += (D2) https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AZD8K_UayDoDFAVs SW Expert AcademySW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!swexpertacademy.com sw expert academy๋‚œ์ด๋„ D2๋ฌธ์ œa์— b๋ฅผ ๋”ํ• ๋•Œ, ํ•ญ์ƒ ๋” ํฐ ์ˆ˜๋ฅผ ๋”ํ•˜๋ฉด ๋œ๋‹ค. ์ตœ๊ทผ์—๋Š” ํ•ญ์ƒ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค๋งŒ ํ’€์–ด์„œ ์ž…๋ ฅ ์ฝ”๋“œ ๋ถ€๋ถ„์ด ๋‚ฏ์„ค์–ด์กŒ๋‹ค๋‹ค์‹œ ์—ฐ์Šตํ•ด์•ผ์ง€!!  ๋‚˜์˜ ํ’€์ด#include #include using namespace std;int answer = 0;void add(int a, int b, int n, int cnt){ if(a + b > n){ an..
[C++/SWEA] 1215. [S/W ๋ฌธ์ œํ•ด๊ฒฐ ๊ธฐ๋ณธ] 3์ผ์ฐจ - ํšŒ๋ฌธ1 (D3) https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV14QpAaAAwCFAYi&categoryId=AV14QpAaAAwCFAYi&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=CCPP&select-1=3&pageSize=10&pageIndex=2 SW Expert AcademySW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!swexpertacademy.com ํšŒ๋ฌธ..๋ฐ˜๋ณต๋ฌธ ์•ˆ์— ๋ณ€์ˆ˜ 2๊ฐœ ๋„ฃ๋Š”๊ฑฐ ์ฒ˜์Œ ํ•ด๋ด„ใ…‹ใ…‹ ์ด์ค‘๋ฐ˜๋ณต๋ฌธ๋ณด๋‹ค ๊น”๋”ํ•˜๊ธด ํ•˜๋‹ค๊ฐ€๋กœ ๊ฐฏ์ˆ˜ ๊ตฌํ•˜๊ณ , ์„ธ๋กœ ๊ฐฏ์ˆ˜ ๊ตฌํ•ด์„œ ๋”ํ•˜๊ธฐ ๋‚˜์˜ ํ’€์ด#inc..
[C++/SWEA] 1206. [S/W ๋ฌธ์ œํ•ด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - View (D3) https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV134DPqAA8CFAYh&categoryId=AV134DPqAA8CFAYh&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=CCPP&select-1=3&pageSize=10&pageIndex=1 SW Expert AcademySW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!swexpertacademy.com ์ตœ๋Œ“๊ฐ’ ์•„์ด๋””์–ด ๋‚˜์˜ ํ’€์ด#include#include#includeusing namespace std;int main(int a..
[C++/PGS] Lv.3 : ์„ฌ ์—ฐ๊ฒฐํ•˜๊ธฐ (๊ทธ๋ฆฌ๋”” Greedy) https://school.programmers.co.kr/learn/courses/30/lessons/42861 ํ”„๋กœ๊ทธ๋ž˜๋จธ์ŠคSW๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ํ‰๊ฐ€, ๊ต์œก, ์ฑ„์šฉ๊นŒ์ง€ Total Solution์„ ์ œ๊ณตํ•˜๋Š” ๊ฐœ๋ฐœ์ž ์„ฑ์žฅ์„ ์œ„ํ•œ ๋ฒ ์ด์Šค์บ ํ”„programmers.co.kr ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๊ทธ๋ฆฌ๋”” - ์„ฌ ์—ฐ๊ฒฐํ•˜๊ธฐ ๋ฌธ์ œ ์›๋ž˜๋Š” ๊ฐ ํŠธ๋ฆฌ์˜ ์ตœ์ƒ๋‹จ ๋ถ€๋ชจ๊ฐ’์„ ์žฌ๊ท€์ ์œผ๋กœ ์ฐพ๋Š” ๊ฒŒ ์ •์„ ํ’€์ด์ธ๋ฐ,๋‚˜๋Š” ๋ณต์žกํ•ด์„œ ๊ทธ๋ƒฅ ์ธ๋ฑ์Šค ๋ฐฐ์—ด์— ์ตœ์†Œ ๋ถ€๋ชจ๊ฐ’๋งŒ ์ €์žฅํ•ด๋†“๊ณ  ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๊ฐฑ์‹ ํ–ˆ๋‹ค. 1. ์ตœ์†Œ ์‹ ์žฅ ํŠธ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด, Greedy๋กœ ์ตœ์†Ÿ๊ฐ’ ๊ฐ„์„ ๋ถ€ํ„ฐ ์ฐพ๋Š” ๊ฒŒ ํฌ์ธํŠธ!2. ๊ฐ ํŠธ๋ฆฌ์˜ ์ตœ์†Œ ๋ถ€๋ชจ๊ฐ’์„ ๋น„๊ตํ•ด์„œ, ๊ฐ™์œผ๋ฉด ํ•œ ํŠธ๋ฆฌ ๋‚ด๋ถ€์— ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ๋ณด๊ณ , ๋‹ค๋ฅด๋‹ค๋ฉด ๋‘ ํŠธ๋ฆฌ๋ฅผ ์ด์–ด์คŒ.  ๋‚˜์˜ ํ’€์ด#include #include #include #..

728x90