diff --git a/taekyoung/20260109/cpp/arrow.cpp b/taekyoung/20260109/cpp/arrow.cpp new file mode 100644 index 000000000..7840e0bbd --- /dev/null +++ b/taekyoung/20260109/cpp/arrow.cpp @@ -0,0 +1,66 @@ +#include +#include + +using namespace std; +vector make_score(vector info, vector scores, vector &best, int n, int k, int diff, int &best_diff); + +vector solution(int n, vector info) { + + int len = info.size(); + vector temp(len); + int score = 0; + + for (int i = 0; i < len; i ++) + { + score -= info[i] ? 10 - i : 0; + } + + vector answer = make_score(info, temp, temp, n, 0, score, score); + + if (score <= 0) return {-1}; + return answer; +} + +vector make_score(vector info, vector scores, vector &best, int n, int k, int diff, int &best_diff) +{ + if (n == 0 || k == 10) + { + scores[k] = n; + if (diff > best_diff) + { + best = scores; + best_diff = diff; + return scores; + } + else if (best_diff > diff) + { + return best; + } + else + { + for(int i = 10; i >= 0; i --) + { + if (scores[i] > best[i]) + { + best = scores; + best_diff = diff; + return scores; + } + else if (scores[i] < best[i]) return best; + } + return best; + } + } + else + { + if (n > info[k]) + { + vector new_score = scores; + new_score[k] = info[k] + 1; + int new_diff = info[k] ? diff + (10 - k) * 2 : diff + (10 - k); + make_score(info, new_score, best, n - (info[k] + 1), k + 1, new_diff, best_diff); + } + make_score(info, scores, best, n, k + 1, diff, best_diff); + } + return best; +} \ No newline at end of file diff --git a/taekyoung/20260109/cpp/working.cpp b/taekyoung/20260109/cpp/working.cpp new file mode 100644 index 000000000..db7a66690 --- /dev/null +++ b/taekyoung/20260109/cpp/working.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +using namespace std; + +int solution(vector schedules, vector> timelogs, int startday) { + + int len = schedules.size(); + int sat = startday == 7 ? 6 : 6 - startday; + int sun = 7 - startday; + int answer = 0; + + for(int i = 0; i < len; i ++) + { + int maginot = schedules[i] + 10; + int remain = maginot % 100; + if (remain >= 60) + { + maginot += 40; + } + + bool recieve = true; + for(int j = 0; j < 7; j ++) + { + if (j == sat || j == sun) continue; + if (timelogs[i][j] > maginot) recieve = false; + } + answer += recieve; + } + + return answer; +} \ No newline at end of file diff --git a/taekyoung/20260109/py/arrow.py b/taekyoung/20260109/py/arrow.py new file mode 100644 index 000000000..283966782 --- /dev/null +++ b/taekyoung/20260109/py/arrow.py @@ -0,0 +1,54 @@ +best_score = 0 +best = [0 for _ in range(11)] + +def solution(n, info): + global best, best_score + answer = [] + + for i in range(len(info)): + if info[i] > 0: + best_score -= 10 - i + + print(best_score) + + make_score(n, 0, best_score, info, [0 for _ in range(11)]) + print(best) + + if best_score <= 0: + return [-1] + + return best + +def make_score(n, k, cur_score, info, arrow): + global best, best_score + if n == 0 or k == 10: + arrow[k] = n + + if cur_score > best_score: + best_score = cur_score + best = arrow + return + elif best_score > cur_score: + return + else: + for i in range(10, -1, -1): + if arrow[i] > best[i]: + best_score = cur_score + best = arrow + return + elif best[i] > arrow[i]: + return + return + else: + if n > info[k]: + new_n = n - (info[k] + 1) + new_arr = arrow[:] + new_arr[k] = info[k] + 1 + new_score = 0 + if info[k] > 0: + new_score = cur_score + (10 - k) * 2 + else: + new_score = cur_score + 10 - k + + make_score(new_n, k + 1, new_score, info, new_arr) + make_score(n, k + 1, cur_score, info, arrow) \ No newline at end of file diff --git a/taekyoung/20260109/py/working.py b/taekyoung/20260109/py/working.py new file mode 100644 index 000000000..172295d9f --- /dev/null +++ b/taekyoung/20260109/py/working.py @@ -0,0 +1,18 @@ +def solution(schedules, timelogs, startday): + answer = 0 + sun = 7 - startday + sat = 6 if sun == 0 else 6 - startday + + for i in range(len(schedules)): + maginot = schedules[i] + 10; + if maginot % 100 >= 60: + maginot += 40 + recieve = 1 + + for t in range(7): + if t != sun and t != sat: + if timelogs[i][t] > maginot: + recieve = 0 + answer += recieve + + return answer \ No newline at end of file diff --git a/taekyoung/20260112/cpp/clothes.cpp b/taekyoung/20260112/cpp/clothes.cpp new file mode 100644 index 000000000..c221f21a3 --- /dev/null +++ b/taekyoung/20260112/cpp/clothes.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +using namespace std; + +int solution(vector> clothes) { + + unordered_map hashmap; + + for(auto c : clothes) + { + hashmap[c[1]]++; + } + + int mult = 1; + + for(auto h : hashmap) + { + mult *= (h.second + 1); + } + + int answer = mult - 1; + return answer; +} \ No newline at end of file diff --git a/taekyoung/20260112/cpp/present.cpp b/taekyoung/20260112/cpp/present.cpp new file mode 100644 index 000000000..42d3d836c --- /dev/null +++ b/taekyoung/20260112/cpp/present.cpp @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include + +using namespace std; + +int strcmp(string str1, string str2) +{ + int str1_len = str1.size(); + int str2_len = str2.size(); + + int min = str1_len > str2_len ? str2_len : str1_len; + + for(int i = 0; i < min; i ++) + { + if (str1[i] > str2[i]) return 1; + else if (str1[i] < str2[i]) return -1; + } + + if (str1_len > str2_len) return 1; + else return -1; +} + +int solution(vector friends, vector gifts) { + + unordered_map record; + unordered_map score; + unordered_map result; + + int fr_len = friends.size(); + + for(int i = 0; i < fr_len - 1; i ++) + { + for(int j = i + 1; j < fr_len; j ++) + { + string str1 = friends[i]; + string str2 = friends[j]; + + if (strcmp(str1, str2) > 0) + { + record[str1 + ' ' + str2] = 0; + } + else + { + record[str2 + ' ' + str1] = 0; + } + } + } + + for(auto g : gifts) + { + istringstream ss(g); + string str1, str2, temp; + int reversed = 1; + + getline(ss, str1, ' '); + getline(ss, str2, ' '); + + score[str1]++; + score[str2]--; + + if (strcmp(str1, str2) < 0) + { + temp = str2; + str2 = str1; + str1 = temp; + reversed = -1; + } + + //cout << str1 + ", " + str2 + " : " << reversed << endl; + + record[str1 + " " + str2] += reversed; + } + + //cout << endl; + + for(auto r : record) + { + //cout << r.first << ", " << r.second << endl; + + istringstream ss(r.first); + string str1, str2; + + getline(ss, str1, ' '); + getline(ss, str2, ' '); + + int record_score = r.second; + + if (record_score > 0) + { + result[str1]++; + } + else if (record_score < 0) + { + result[str2]++; + } + else + { + int score_first = score[str1]; + int score_second = score[str2]; + + if (score_first > score_second) + { + result[str1]++; + } + else if (score_second > score_first) + { + result[str2]++; + } + } + } + + int answer = 0; + for(auto r : result) + { + if (r.second > answer) answer = r.second; + } + + return answer; +} \ No newline at end of file