CodingTest Exam (110) 썸네일형 리스트형 1-2. 오렌지 나무 ★★★★☆ #include #include using namespace std; vector x; vector y; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int w, h, t, s, a, b; cin >> w >> h >> t >> s; for(int i = 0; i > a >> b; x.push_back(a); y.push_back(b); } int x1 = 0, y1 = 0; int count = 0; int res = 0; for(int i = 0; i .. 1-1. 공통 문자열 ★★☆☆☆ #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string str, res, ch, temp = ""; vector V; for(int i = 1; i > str; V.push_back(str); } res = V[0]; for(int i = 1; i < V.size(); i++) { str = V[i]; ch.clear(); for(int j = 0; j < str.size(); j++) { if(res[j] == string::npos || res[j] != str[j]) break; if(res[j] == str[j]) ch .. 103. 위상정렬(그래프 정렬) (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★★★☆☆ #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, a, b, x = 0; cin >> n >> m; vector Degree(n+1, 0); vector Work[n+1]; queue Q; for(int i = 1; i > a >> b; Work[a].push_back(b); } for(int i = 1; i 102. 회장뽑기(플로이드-워샬 응용) (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★★★☆☆ #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, a, b, score = 2147000000, cnt = 0; cin >> n; vector V(n+1, vector(n+1, 100)); vector Scores(n+1, 0); while(true) { cin >> a >> b; if(a == -1 && b == -1) break; V[a][b] = 1; V[b][a] = 1; } for(int k = 1; k 101. 플로이드 워샬 알고리 (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★★★☆☆ #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, a, b, c; cin >> n >> m; vector dis(n+1, vector(n+1, 5000)); for(int i = 1; i a >> b >> c; dis[a][b] = c; } for(int k = 1; k 100. 최대점수 구하기(냅색 알고리즘) (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★★☆☆☆ #include #include using namespace std; struct Exam { int score; int time; Exam(int x, int y) { this -> score = x; this -> time = y; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, a, b; cin >> n >> m; vector V; vector Scores(m+1, 0); V.push_back(Exam(0, 0)); for(int i = 0; i > a >> b; V.push_back(Exam(a, b)); } for(int i = 1; i = 0; j--) { if(j - exam.t.. 99. 동전교환(냅색 알고리즘) (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★★☆☆☆ #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, a; cin >> n; vector C; for(int i = 0; i > a; C.push_back(a); } cin >> m; vector V(m+1, 0); for(int i = 0; i V[j-C[i]] + 1 || V[j] == 0) V[j] = V[j-C[i]] + 1; } } cout 98. 가방문제(냅색 알고리즘) (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★★☆☆☆ #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, a, b; cin >> n >> m; vector V; vector Bag(m+1, 0); for(int i = 1; i > a >> b; V.push_back(make_pair(a, b)); } for(int i = 0; i < V.size(); i++) { int w = V[i].first; int v = V[i].second; for(int j = 0; j < Bag.size(); j++) { if(j - w < 0) continue; if(Bag[j] < Bag[j-w] + v) Bag[j] = Bag[j-.. 이전 1 2 3 4 5 ··· 14 다음