2024/10 13

[백준 BOJ] 2473 세 용액 C++

2470 두 용액 문제의 응용이다.  입력첫째줄: 전체 용액의 수 N (3 둘째줄: 용액의 특성값 (-10^9 ~ 10^9)출력특성값을 0에 가깝게 만드는 세 용액의 특성값 출력 (오름차순으로)풀이1️⃣ - 시간초과#include #include #include #include #define INF 987654321using namespace std;int N;vector v;vector answer;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> N; int a; for (int i=0;i> a; v.push_back(a); } sort(v.begin(), v.end()); in..

Algorithm 2024.10.03

백트래킹

1. 프로그래머스 2022 Kakao Blind Recruitment 양궁대회  프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이1️⃣ - 오답// 라이언 b vs 어피치 a// 규칙: a>=b면 어피치가 k점, a 2^11의 경우가 존재#include #include using namespace std;int arr[11];int max_diff = 0;vector ryan(11, 0);vector apeach;vector answer = { -1 };int cmp(vector ryan, vector apeach) { int ryan_score = 0..

Algorithm 2024.10.01

[프로그래머스 level1] 개인정보 수집 유효기간 C++

프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 풀이 1️⃣ - 오답// 입력: 약관 종류 arr[i] | 약관 유효기간 terms[i]// 입력: 번호 n | 오늘 날짜 today | 약관 종류 string -> 개인정보수집날짜+약관종류 privacies[i] // 출력: 파기해야하는 개인정보의 번호#include #include #include using namespace std;vector solution(string today, vector terms, vector privacies) { vector answer; // today: 2..

Algorithm 2024.10.01