프로그래머스72 순위 C++ #include #include #include #include #include using namespace std; int solution(int n, vector results) { int answer = 0; int win[101][101]; memset(win, 0, sizeof(win)); for (int i = 0; i < results.size(); i++) win[results[i][0]][results[i][1]] = 1; for (int i = 1; i 2019. 9. 30. 저울 C++ #include #include using namespace std; int solution(vector weight) { int answer = 0; int sum = 0; sort(weight.begin(), weight.end()); for (int i = 0; i < weight.size(); i++) { if (sum + 1 < weight[i]) break; sum += weight[i]; } return answer = sum + 1; } 2019. 9. 30. 이중우선순위큐 C++ #include #include #include using namespace std; vector solution(vector operations) { vector answer; vector v; for (int i = 0; i < operations.size(); i++) { if (operations[i][0] == 'D') { sort(v.begin(), v.end()); if (v.size() == 0) continue; else { if (operations[i][2] == '1') v.erase(v.begin() + v.size() - 1); else v.erase(v.begin()); } } else { v.push_back(stoi(operations[i].substr(2))); } } i.. 2019. 9. 29. 여행경로 C++ #include #include #include #include #include using namespace std; const int MAX = 100000001; vector temp; int visited[MAX]; bool dfs(string str,int count, vector t) { if (count == t.size()) return true; for (int i = 0; i < t.size(); i++) { if (t[i][0] == str && visited[i] == -1) { temp.push_back(t[i][1]); visited[i] = 1; if (dfs(t[i][1], count + 1, t)) return true; visited[i] = -1; temp.pop_back.. 2019. 9. 29. 이전 1 ··· 12 13 14 15 16 17 18 다음