diff --git "a/\354\247\200\354\235\200/boj/13458.cpp" "b/\354\247\200\354\235\200/boj/13458.cpp" new file mode 100644 index 0000000..f77e814 --- /dev/null +++ "b/\354\247\200\354\235\200/boj/13458.cpp" @@ -0,0 +1,34 @@ +#include +#include +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + long long answer = 0; + int n, b, c; + cin >> n; + + vector a(n); + for (int i = 0; i < n; i++) + cin >> a[i]; + + cin >> b >> c; + + for (int i = 0; i < n; i++) { + a[i] -= b; + answer++; + + if (a[i] > 0) { + answer += a[i] / c; + if (a[i] % c != 0) { + answer++; + } + } + } + + cout << answer; + + return 0; +} \ No newline at end of file diff --git "a/\354\247\200\354\235\200/boj/1987.cpp" "b/\354\247\200\354\235\200/boj/1987.cpp" new file mode 100644 index 0000000..19de419 --- /dev/null +++ "b/\354\247\200\354\235\200/boj/1987.cpp" @@ -0,0 +1,50 @@ +#include +#include +#include +using namespace std; + +int r, c, answer; +int dx[] = { 1,0,-1,0 }; +int dy[] = { 0,1,0,-1 }; +char board[20][20]; +bool alphabet[26]; + +void dfs(int cnt, int y, int x) { + for (int i = 0; i < 4; i++) { + int next_y = y + dy[i]; + int next_x = x + dx[i]; + + if (next_y < 0 || next_y >= r || next_x < 0 || next_x >= c) + continue; + + if (!alphabet[board[next_y][next_x] - 'A']) { + alphabet[board[next_y][next_x] - 'A'] = true; + + dfs(cnt + 1, next_y, next_x); + + alphabet[board[next_y][next_x] - 'A'] = false; + } + } + + if (answer < cnt) + answer = cnt; +} + +int main() { + cin >> r >> c; + + for (int i = 0; i < r; i++) { + string str; + cin >> str; + for (int j = 0; j < str.size(); j++) { + board[i][j] = str[j]; + } + } + + alphabet[board[0][0] - 'A'] = true; + dfs(1, 0, 0); + + cout << answer; + + return 0; +} \ No newline at end of file