diff --git "a/weekly/week04/BOJ_14925_\353\252\251\354\236\245\352\261\264\354\204\244\355\225\230\352\270\260/Gyuhyeok99.cpp" "b/weekly/week04/BOJ_14925_\353\252\251\354\236\245\352\261\264\354\204\244\355\225\230\352\270\260/Gyuhyeok99.cpp" new file mode 100644 index 0000000..3626d48 --- /dev/null +++ "b/weekly/week04/BOJ_14925_\353\252\251\354\236\245\352\261\264\354\204\244\355\225\230\352\270\260/Gyuhyeok99.cpp" @@ -0,0 +1,37 @@ +#include + +using namespace std; + +int n, m, ret; +int arr[1001][1001], dp[1001][1001]; + +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + cin >> m >> n; + + for (int i = 1; i <= m; i++) { + for (int j= 1; j <= n; j++) { + cin >> arr[i][j]; + } + } + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (!arr[i][j]) { + if (!dp[i - 1][j - 1] || !dp[i][j - 1] || !dp[i - 1][j]) { + dp[i][j] = 1; + } + else { + dp[i][j] = min(min(dp[i - 1][j - 1], dp[i][j - 1]), dp[i - 1][j]) + 1; + } + ret = max(ret, dp[i][j]); + } + } + } + + cout << ret << '\n'; + + return 0; +} diff --git "a/weekly/week05/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644/Gyuhyeok99.cpp" "b/weekly/week05/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644/Gyuhyeok99.cpp" new file mode 100644 index 0000000..2ece1b5 --- /dev/null +++ "b/weekly/week05/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644/Gyuhyeok99.cpp" @@ -0,0 +1,34 @@ +#include +#include +#include + +using namespace std; + +int t, n, ret; +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + cin >> t; + while (t--) { + cin >> n; + vector> scores; + ret = 1; + for (int i = 0; i < n; i++) { + int a, b; + cin >> a >> b; + scores.push_back({a, b}); + } + sort(scores.begin(), scores.end()); + + int _max = scores[0].second; + for (int i = 1; i < n; i++) { + if (scores[i].second <= _max) { + _max = scores[i].second; + ret++; + } + } + cout << ret << '\n'; + } + return 0; +} diff --git "a/weekly/week05/BOJ_1781_\354\273\265\353\235\274\353\251\264/Gyuhyeok99.cpp" "b/weekly/week05/BOJ_1781_\354\273\265\353\235\274\353\251\264/Gyuhyeok99.cpp" new file mode 100644 index 0000000..176a404 --- /dev/null +++ "b/weekly/week05/BOJ_1781_\354\273\265\353\235\274\353\251\264/Gyuhyeok99.cpp" @@ -0,0 +1,35 @@ +#include +#include +#include +#include +using namespace std; + +priority_queue, greater> pq; +vector> v; +int n, p, d, ret; +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + cin >> n; + for (int i = 0; i < n; i++) { + cin >> d >> p; + v.push_back({d, p}); + } + sort(v.begin(), v.end()); + for (int i = 0; i < n; i++) { + pq.push(v[i].second); + if (v[i].first < pq.size()) { + pq.pop(); + } + } + + while (pq.size()) { + ret += pq.top(); + pq.pop(); + } + + cout << ret << '\n'; + + return 0; +} diff --git "a/weekly/week05/BOJ_6236_\354\232\251\353\217\210\352\264\200\353\246\254/Gyuhyeok99.cpp" "b/weekly/week05/BOJ_6236_\354\232\251\353\217\210\352\264\200\353\246\254/Gyuhyeok99.cpp" new file mode 100644 index 0000000..605c81f --- /dev/null +++ "b/weekly/week05/BOJ_6236_\354\232\251\353\217\210\352\264\200\353\246\254/Gyuhyeok99.cpp" @@ -0,0 +1,45 @@ +#include +#include + +using namespace std; + +int n, m, l, r, ret = 987654321; +int arr[100001]; + +bool check(int mid) { + int cnt = 1; + int sum = 0; + for(int i = 0; i < n; i++) { + if(sum + arr[i] > mid) { + cnt++; + sum = 0; + } + sum += arr[i]; + } + return cnt <= m; +} +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + cin >> n >> m; + for(int i = 0; i < n; i++) { + cin >> arr[i]; + r += arr[i]; + l = max(l, arr[i]); + } + + while(l <= r) { + int mid = (l + r) / 2; + if(check(mid)) { + ret = mid; + r = mid - 1; + } + else { + l = mid + 1; + } + } + cout << ret << '\n'; + return 0; +} \ No newline at end of file