본문 바로가기

카카오 코딩 테스트 풀이8

무지의 먹방 라이브 #include #include #include using namespace std; const int MAX = 1001; vector v; bool cmp(pair a, pair b) { if (a.second < b.second) return true; return false; } int solution(vector food_times, long long k) { int answer = -1; int counts = 0; int n = food_times.size(); for (int i = 0; i < food_times.size(); i++) { v.push_back(make_pair(food_times[i],i+1)); } sort(v.begin(), v.end()); for (vector::.. 2019. 9. 2.
후보키 풀이 #include #include #include using namespace std; int bitnum(int i) { int counts = 0; while (i != 0) { if (i & 1) counts++; i = i >> 1; } return counts; } bool cmp(int a, int b) { if (bitnum(a) > bitnum(b)) return true; return false; } bool uniquecheck(vector v, int r, int c, int subset) { for (int i = 0; i < r-1; i++) { for (int j = i + 1; j < r; j++) { bool samecheck = true; for (int k = 0; k < .. 2019. 9. 2.
실패율 풀이 #include #include #include #include #include using namespace std; const int MAX = 501; bool cmp(pair a, pair b) { if (a.first > b.first) return true; else if (a.first == b.first) { if (a.second < b.second) return true; else return false; } return false; } vector solution(int N, vector stages) { vector answer; int num[MAX],current[MAX]; vector value; memset(num, 0, sizeof(num)); memset(current, 0.. 2019. 9. 1.
오픈채팅방 풀이 #include #include #include #include using namespace std; vector solution(vector record) { vector answer; queue q; map id; for (int i = 0; i < record.size(); i++) { string str; vector temp; for (int j = 0; j < record[i].size(); j++) { if (record[i][j] == ' ') { temp.push_back(str); str.clear(); } else str.push_back(record[i][j]); } temp.push_back(str); if(temp[0][0] == 'C'){ id[temp[1]] = temp[2].. 2019. 9. 1.