BOJ

알고리즘 문제 풀이/1DP_과제(~180615)

180424_1032_베스트셀러

//https://www.acmicpc.net/problem/1032 #include #include #include #include using namespace std; struct book{ int idx; int cnt; string title; book(); book(int idx, string title, int cnt) : idx(idx), title(title), cnt(cnt) {}}; bool cmp(book a, book b){ if(a.cnt != b.cnt) return a.cnt> b.cnt; else { if(a.title.compare(b.title) < 0) return true; //사전 순으로 a가 b의 앞일 때 else return false; }}int main(){ ..

알고리즘 문제 풀이/1DP_과제(~180615)

180424_1068_트리

//https://www.acmicpc.net/problem/1068 #include #include using namespace std; int tree[50][50];//tree[i][0] : i 번째 노드의 자식 수 //tree[i][j] : i번째 노드의 자식 indexint n, d, ans;void search(int tmp);int main(){ cin >> n; int root; for(int i=0; i> p; if(p==-1) root=i; else{ tree[p][0]++; tree[p][tree[p][0]]=i; } } cin >> d; if(root==d) { cout

알고리즘 문제 풀이/1DP_과제(~180615)

180423_10825_국영수

//https://www.acmicpc.net/problem/10825 #include #include #include #include #include using namespace std; struct stu{public: string name; int kor; int eng; int math;}; bool cmp(stu a, stu b){ if(a.kor>b.kor) return true; if(a.kor==b.kor){ if(a.eng b.math) return true; if(a.math==b.math) { if(a.name.compare(b.name) a.name; scanf("%d %d %d", &a.kor..

알고리즘 문제 풀이/1DP_과제(~180615)

180423_10814_나이순 정렬

//https://www.acmicpc.net/problem/10814#include #include #include #include #include using namespace std; struct cus{ int age; int idx; char *name[20];}; bool cmp(cus a, cus b){ if(a.age < b.age) return true; if(a.age==b.age){ return a.idx

bong sue
'BOJ' 태그의 글 목록 (2 Page)