Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions taekyoung/20260109/cpp/arrow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <string>
#include <vector>

using namespace std;
vector<int> make_score(vector<int> info, vector<int> scores, vector<int> &best, int n, int k, int diff, int &best_diff);

vector<int> solution(int n, vector<int> info) {

int len = info.size();
vector<int> temp(len);
int score = 0;

for (int i = 0; i < len; i ++)
{
score -= info[i] ? 10 - i : 0;
}

vector<int> answer = make_score(info, temp, temp, n, 0, score, score);

if (score <= 0) return {-1};
return answer;
}

vector<int> make_score(vector<int> info, vector<int> scores, vector<int> &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<int> 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;
}
33 changes: 33 additions & 0 deletions taekyoung/20260109/cpp/working.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int solution(vector<int> schedules, vector<vector<int>> 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;
}
54 changes: 54 additions & 0 deletions taekyoung/20260109/py/arrow.py
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions taekyoung/20260109/py/working.py
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions taekyoung/20260112/cpp/clothes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int solution(vector<vector<string>> clothes) {

unordered_map<string, int> 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;
}
122 changes: 122 additions & 0 deletions taekyoung/20260112/cpp/present.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#include <string>
#include <sstream>
#include <vector>
#include <unordered_map>
#include <iostream>

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<string> friends, vector<string> gifts) {

unordered_map<string, int> record;
unordered_map<string, int> score;
unordered_map<string, int> 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;
}