Skip to content

Commit

Permalink
Merge pull request #138 from cje172/main
Browse files Browse the repository at this point in the history
[Week 50] 최지은
  • Loading branch information
cje172 authored Apr 15, 2024
2 parents b716209 + d53d0af commit d8ca144
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 지은/boj/13458.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
#include <vector>
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<int> 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;
}
50 changes: 50 additions & 0 deletions 지은/boj/1987.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>
#include <string>
#include <algorithm>
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;
}

0 comments on commit d8ca144

Please sign in to comment.