Algorithm/BOJ
-
열쇠 - 9328Algorithm/BOJ 2020. 3. 12. 02:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12..
-
백조의 호수 - 3197Algorithm/BOJ 2020. 3. 11. 05:37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 //3197 - 백조의 호수 #include #include #include..
-
학교 탐방하기 - 13418Algorithm/BOJ 2020. 3. 11. 01:57
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 //13418 - 학교 탐방하기 #include #include using namespace std; int N, M; vector up; vector down; struct DisjointSet { vector parent, rank; DisjointSet(int n) : parent(n), rank(n, 1) ..
-
숫자구슬 - 2613Algorithm/BOJ 2020. 3. 10. 19:22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 //2613 - 숫자구슬 #include #include using namespace std; int N, M; int arr[301]; int sub[301]; int main() { int left = 0; cin >> N >> M; for(int i = 1; i> arr[i], left = max(left, arr[i]); sub[0] = 0; for..
-
공유기 설치 - 2110Algorithm/BOJ 2020. 3. 10. 02:22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 //2110 - 공유기 설치 #include #include using namespace std; int N, M; int arr[200000]; void init() { cin >> N >> M; for (int i = 0; i > arr[i]; sort(arr, arr + N); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); init(); int left = 1; int right = arr[N - 1] - ..
-
버블 소트 - 1517Algorithm/BOJ 2020. 3. 8. 07:39
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 //1517 - 버블 솔트 #include #include #include using namespace std; int N; pair arr[500000]; struct FenwickTree { vector tree; FenwickTree(int n) : tree(n, 0) {} int sum(int pos) { ++pos; int ret = 0; while(pos) { ret += tree[pos..