Skip to content

Commit 33d4921

Browse files
Merge pull request #528 from dongmin115/main
[임동민] 65차 라이브코테 제출
2 parents a4a42e7 + 7ef069c commit 33d4921

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

live6/test65/문제1/임동민.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map(e => e.split(''));
7+
8+
function solution() {
9+
const board = input.slice(1);
10+
let result= 0;
11+
12+
function getMaxCandy(){
13+
let max = 0;
14+
15+
for(let i=0; i<board.length;i++){
16+
let count = 1;
17+
for(let j=0; j<board.length -1; j++){
18+
if(board[i][j] === board[i][j+1]){
19+
count++;
20+
} else {
21+
max = Math.max(max, count);
22+
count = 1;
23+
}
24+
}
25+
max = Math.max(max, count);
26+
}
27+
28+
for(let i=0; i<board.length;i++){
29+
let count = 1;
30+
for(let j=0; j<board.length -1; j++){
31+
if(board[j][i] === board[j+1][i]){
32+
count++;
33+
} else {
34+
max = Math.max(max, count);
35+
count = 1;
36+
}
37+
}
38+
max = Math.max(max, count);
39+
}
40+
41+
return max;
42+
}
43+
44+
for(let i=0; i<board.length; i++){
45+
for(let j=0; j<board.length; j++){
46+
if(j+1 < board.length){
47+
[board[i][j], board[i][j+1]] = [board[i][j+1], board[i][j]];
48+
result = Math.max(result, getMaxCandy());
49+
[board[i][j], board[i][j+1]] = [board[i][j+1], board[i][j]];
50+
}
51+
52+
if(i+1 < board.length){
53+
[board[i][j], board[i+1][j]] = [board[i+1][j], board[i][j]];
54+
result = Math.max(result, getMaxCandy());
55+
[board[i][j], board[i+1][j]] = [board[i+1][j], board[i][j]];
56+
}
57+
}
58+
}
59+
60+
console.log(result);
61+
62+
}
63+
64+
solution();

live6/test65/문제2/임동민.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map(e => e.split(' ').map(Number));
7+
8+
function solution() {
9+
const N = input[0][0];
10+
const calendar = input.slice(1);
11+
let max = 0;
12+
13+
function recursive(day,pay){
14+
if(day > N){
15+
max = Math.max(max, pay);
16+
return;
17+
}
18+
19+
recursive(day + 1, pay);
20+
21+
if(day + calendar[day-1][0] -1 <= N){
22+
recursive(day + calendar[day-1][0], pay + calendar[day-1][1]);
23+
}
24+
}
25+
26+
recursive(1,0);
27+
28+
console.log(max);
29+
}
30+
31+
solution();

live6/test65/문제3/임동민.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function solution(s)
2+
{
3+
const stack = [];
4+
5+
for(let i=0; i<s.length; i++){
6+
if(s[i] === stack[stack.length -1]){
7+
stack.pop();
8+
} else {
9+
stack.push(s[i]);
10+
}
11+
}
12+
13+
return stack.length === 0 ? 1 : 0;
14+
}

0 commit comments

Comments
 (0)