[백준] 2776번 암기왕 (이분탐색)
-문제 -코드 #include #include #include using namespace std; int main() { int t, n, m, lt, rt, mid, cnt = 0, key; scanf("%d", &t); for (int i = 0; i < t; i++) { scanf("%d", &n); vector a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } scanf("%d", &m); sort(a.begin(), a.end()); for (int i = 0; i < m; i++) { scanf("%d", &key); lt = 0; rt = n - 1; cnt = 0; while (lt
2022. 8. 25.
[백준] 1590번 캠프가는 영식 (그리디 알고리즘)
-문제 -코드 #include #include using namespace std; int main() { int n, t, wait=2147000000, bs,bi,bc, tmp; scanf("%d %d", &n, &t); for (int i = 0; i tmp) wait = tmp; } } } if (wait == 2147000000) printf("%d", -1); else printf("%d", wai..
2022. 8. 25.
[백준] 11256번 사탕 (그리디 알고리즘)
-문제 -코드 #include #include #include using namespace std; int main() { int t, j, n, r, c, res = 0; scanf("%d", &t); vector a; for (int i = 0; i < t; i++) { scanf("%d %d", &j, &n); a.clear(); res = 0; for (int i = 0; i < n; i++) { scanf("%d %d", &r, &c); a.push_back(r*c); } sort(a.rbegin(), a.rend()); for (int i = 0; i < n; i++) { j -= a[i]; res++; if (j
2022. 8. 24.