Algorithm ๐ง๐ป๐ป457 [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์์ฐ์ ๋ค์ง์ด ๋ฐฐ์ด๋ก ๋ง๋ค๊ธฐ( Level 1) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์์ฐ์ ๋ค์ง์ด ๋ฐฐ์ด๋ก ๋ง๋ค๊ธฐ ์์ฐ์ n์ ๋ค์ง์ด ๊ฐ ์๋ฆฌ ์ซ์๋ฅผ ์์๋ก ๊ฐ์ง๋ ๋ฐฐ์ด ํํ๋ก ๋ฆฌํดํด์ฃผ์ธ์. ์๋ฅผ๋ค์ด n์ด 12345์ด๋ฉด [5,4,3,2,1]์ ๋ฆฌํดํฉ๋๋ค. ์ ํ ์กฐ๊ฑด n์ 10,000,000,000์ดํ์ธ ์์ฐ์์ ๋๋ค. ์ ์ถ๋ ฅ ์ n return 12345 programmers.co.kr ์ฝ๋ #include #include #include using namespace std; vector solution(long long n) { vector answer; string s; s=to_string(n); reverse(s.begin(),s.end()); for(int i=0; i 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ด์ค ์ฐ์ ์์ํ( Level 3) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์ด์ค์ฐ์ ์์ํ programmers.co.kr ์ฝ๋ #include #include #include #include using namespace std; vector solution(vector operations) { vectoranswer; multisetset; for(int i=0; i 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ด์ํ ๋ฌธ์ ๋ง๋ค๊ธฐ( Level 1) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์ด์ํ ๋ฌธ์ ๋ง๋ค๊ธฐ ๋ฌธ์์ด s๋ ํ ๊ฐ ์ด์์ ๋จ์ด๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค. ๊ฐ ๋จ์ด๋ ํ๋ ์ด์์ ๊ณต๋ฐฑ๋ฌธ์๋ก ๊ตฌ๋ถ๋์ด ์์ต๋๋ค. ๊ฐ ๋จ์ด์ ์ง์๋ฒ์งธ ์ํ๋ฒณ์ ๋๋ฌธ์๋ก, ํ์๋ฒ์งธ ์ํ๋ฒณ์ ์๋ฌธ์๋ก ๋ฐ๊พผ ๋ฌธ์์ด์ programmers.co.kr ์ฝ๋ #include #include using namespace std; string solution(string s) { string answer = ""; int cnt=0; for(int i=0; i 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์์ ๋ํ๊ธฐ( Level 1) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์์ ๋ํ๊ธฐ ์ด๋ค ์ ์๋ค์ด ์์ต๋๋ค. ์ด ์ ์๋ค์ ์ ๋๊ฐ์ ์ฐจ๋ก๋๋ก ๋ด์ ์ ์ ๋ฐฐ์ด absolutes์ ์ด ์ ์๋ค์ ๋ถํธ๋ฅผ ์ฐจ๋ก๋๋ก ๋ด์ ๋ถ๋ฆฌ์ธ ๋ฐฐ์ด signs๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. ์ค์ ์ ์๋ค์ ํฉ์ ๊ตฌํ์ฌ re programmers.co.kr ์ฝ๋ #include #include using namespace std; int solution(vector absolutes, vector signs) { int answer = 0; for(int i=0; i 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์์ฃผํ์ง ๋ชปํ ์ ์( Level 1) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์์ฃผํ์ง ๋ชปํ ์ ์ ์๋ง์ ๋ง๋ผํค ์ ์๋ค์ด ๋ง๋ผํค์ ์ฐธ์ฌํ์์ต๋๋ค. ๋จ ํ ๋ช ์ ์ ์๋ฅผ ์ ์ธํ๊ณ ๋ ๋ชจ๋ ์ ์๊ฐ ๋ง๋ผํค์ ์์ฃผํ์์ต๋๋ค. ๋ง๋ผํค์ ์ฐธ์ฌํ ์ ์๋ค์ ์ด๋ฆ์ด ๋ด๊ธด ๋ฐฐ์ด participant์ ์์ฃผํ ์ ์ programmers.co.kr ์ฝ๋ #include #include #include using namespace std; string solution(vector participant, vector completion) { string answer = ""; map people; for(string par: participant) people[par]++; for(string comple: completion) people[comple]--; for(auto it =.. 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์คํ์ฑํ ๋ฐฉ( Level 2, 2019 ์นด์นด์ค ๋ธ๋ผ์ธ๋) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์คํ์ฑํ ๋ฐฉ ์คํ์ฑํ ๋ฐฉ ์นด์นด์คํก ์คํ์ฑํ ๋ฐฉ์์๋ ์น๊ตฌ๊ฐ ์๋ ์ฌ๋๋ค๊ณผ ๋ํ๋ฅผ ํ ์ ์๋๋ฐ, ๋ณธ๋ ๋๋ค์์ด ์๋ ๊ฐ์์ ๋๋ค์์ ์ฌ์ฉํ์ฌ ์ฑํ ๋ฐฉ์ ๋ค์ด๊ฐ ์ ์๋ค. ์ ์ ์ฌ์์ธ ๊นํฌ๋ฃจ๋ ์นด์นด์คํก ์ค programmers.co.kr ํต๊ณผ ์ฝ๋ #include #include #include using namespace std; struct DB{ string status; string id; string name; }; mapm; vectoruserDB; void inp(string s){ int cnt=0; DB db; string temp; for(int i=0; i 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์์ฐ( Level 1) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์์ฐ S์ฌ์์๋ ๊ฐ ๋ถ์์ ํ์ํ ๋ฌผํ์ ์ง์ํด ์ฃผ๊ธฐ ์ํด ๋ถ์๋ณ๋ก ๋ฌผํ์ ๊ตฌ๋งคํ๋๋ฐ ํ์ํ ๊ธ์ก์ ์กฐ์ฌํ์ต๋๋ค. ๊ทธ๋ฌ๋, ์ ์ฒด ์์ฐ์ด ์ ํด์ ธ ์๊ธฐ ๋๋ฌธ์ ๋ชจ๋ ๋ถ์์ ๋ฌผํ์ ๊ตฌ๋งคํด ์ค ์๋ programmers.co.kr ์ฝ๋ #include #include #include #include #include using namespace std; int solution(vector d, int budget) { int answer = 0; sort(d.begin(),d.end()); for(int i=0; i 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์คํจ์จ( Level 1) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์คํจ์จ ์คํจ์จ ์ํผ ๊ฒ์ ๊ฐ๋ฐ์ ์ค๋ ๋ฆฌ๋ ํฐ ๊ณ ๋ฏผ์ ๋น ์ก๋ค. ๊ทธ๋ ๊ฐ ๋ง๋ ํ๋์ฆ ์ค์ฒ์ฑ์ด ๋์ฑ๊ณต์ ๊ฑฐ๋์ง๋ง, ์์ฆ ์ ๊ท ์ฌ์ฉ์์ ์๊ฐ ๊ธ๊ฐํ ๊ฒ์ด๋ค. ์์ธ์ ์ ๊ท ์ฌ์ฉ์์ ๊ธฐ์กด ์ฌ์ฉ์ ์ฌ์ด์ ์ค programmers.co.kr ์ฝ๋ #include #include #include #include using namespace std; mapm; vectorfault; bool cmp(paira,pairb){ if(a.second==b.second) return a.firstb.second; } vector solution(int N, vector stages) { vector answer; for(int i=0; i=i){ total_peo+=k->second; } } if(tot.. 2021. 10. 22. [c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ ๊ท ์์ด๋ ์ถ์ฒ( Level 1, 2021 ์นด์นด์ค ๋ธ๋ผ์ธ๋) ๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์ ๊ท ์์ด๋ ์ถ์ฒ ์นด์นด์ค์ ์ ์ฌํ ์ ์ ๊ฐ๋ฐ์ ๋ค์ค๋ "์นด์นด์ค๊ณ์ ๊ฐ๋ฐํ"์ ๋ฐฐ์น๋์ด, ์นด์นด์ค ์๋น์ค์ ๊ฐ์ ํ๋ ์ ์ ๋ค์ ์์ด๋๋ฅผ ์์ฑํ๋ ์ ๋ฌด๋ฅผ ๋ด๋นํ๊ฒ ๋์์ต๋๋ค. "๋ค์ค"์๊ฒ ์ฃผ์ด์ง ์ฒซ ์ ๋ฌด๋ ์๋ก programmers.co.kr ์ฝ๋ #include #include #include #include using namespace std; string solution(string new_id) { string answer = ""; string id = new_id; transform(id.begin(), id.end(), id.begin(), ::tolower); //1๋จ๊ณ string temp=""; for(int i=0; i=16){ //6๋จ๊ณ while(id.length(.. 2021. 10. 22. ์ด์ 1 ยทยทยท 43 44 45 46 47 48 49 ยทยทยท 51 ๋ค์