본문 바로가기

C++

(226)
[Programmers] 주차 요금 계산 (C++) https://school.programmers.co.kr/learn/courses/30/lessons/92341 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; vector solution(vector fees, vector records) { vector answer; map inCar; map outCar; for(int i = 0; i < records.size(); i++){ int time = stoi(records[i].substr(0, 3))..
[Programmers] 괄호 변환 (C++) https://school.programmers.co.kr/learn/courses/30/lessons/60058 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; string solution(string p) { string answer = ""; // 1. if(p == "") return answer; // 2. string u = "", v = ""; int open = 0, close = 0; for(int i = 0; i < p.length(); i++){ if(..
[Programmers] 신고 결과 받기 (C++) https://school.programmers.co.kr/learn/courses/30/lessons/92334 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; vector solution(vector id_list, vector report, int k) { vector answer(id_list.size(), 0); // 한 유저가 같은 유저를 여러 번 신고한 경우는 신고 횟수 1회 처리 // -> report에서 같은 값 제거 sort(report...
[Programmers] 성격 유형 검사하기 (C++) https://school.programmers.co.kr/learn/courses/30/lessons/118666 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; string solution(vector survey, vector choices) { string answer = ""; map m; for(int i = 0; i < survey.size(); i++){ if(choices[i] == 1) m[survey[i][0]] += 3; else if(choices[..
[Programmers] 개인정보 수집 유효기간 (C++) https://school.programmers.co.kr/learn/courses/30/lessons/150370 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; vector solution(string today, vector terms, vector privacies) { vector answer; int today_num = stoi(today.substr(0, 4)) * 12 * 28 + stoi(today.substr(5, 7)) * 28 + stoi(today..
[BOJ] 1563번 개근상 (C++) https://www.acmicpc.net/problem/1563 1563번: 개근상 백준중학교에서는 학기가 끝날 무렵에 출결사항을 보고 개근상을 줄 것인지 말 것인지 결정한다. 이 학교는 이상해서 학생들이 학교를 너무 자주 빠지기 때문에, 개근상을 주는 조건이 조금 독 www.acmicpc.net #include #include using namespace std; const int divval = 1000000; int dp[1001][2][3]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; dp[1][0][0] = dp[1][1][0] = dp[1][0][1] = 1; for(int i = 2; i dp[n][0..
[BOJ] 5567번 결혼식 (C++) https://www.acmicpc.net/problem/5567 5567번: 결혼식 예제 1의 경우 2와 3은 상근이의 친구이다. 또, 3과 4는 친구이기 때문에, 4는 상근이의 친구의 친구이다. 5와 6은 친구도 아니고, 친구의 친구도 아니다. 따라서 2, 3, 4 3명의 친구를 결혼식에 초대 www.acmicpc.net #include #include #include #include using namespace std; int n, m; vector v[501]; bool visited[501]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 0; i < m; i++){ int a, b; cin ..
[BOJ] 5502번 팰린드롬 (C++) https://www.acmicpc.net/problem/5502 5502번: 팰린드롬 팰린드롬이란 대칭 문자열이다. 즉, 왼쪽에서 오른쪽으로 읽었을때와 오른쪽에서 왼쪽으로 읽었을때 같다는 얘기다. 당신은 문자열이 주어졌을때, 최소 개수의 문자를 삽입하여 팰린드롬이 www.acmicpc.net #include #include #include using namespace std; int dp[5001][5001]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s, r_s; cin >> s; r_s = s; reverse(r_s.begin(), r_s.end()); for(int i = 1; i