20250606 baekjoon javascript

This commit is contained in:
songyc macbook 2025-06-06 18:32:23 +09:00
parent 2ef38a21d2
commit 375eabe025
4 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,15 @@
const input = require("fs").readFileSync(0,"utf8").toString().trim().split("\n");
let s="";
for(let col=0; col<15; col++){
let flag = true;
for(let row=0; row<5; row++){
if(input[row][col] !== undefined){
s += input[row][col];
flag = false;
}
}
if(flag) break;
}
console.log(s);

View File

@ -0,0 +1,17 @@
const input = require("fs").readFileSync(0,"utf8").toString().split("\n");
let paper = Array.from({length:100},()=>new Array(100).fill(0));
let sum=0;
for(let n=1; n<=Number(input[0]); n++){
let [x, y] = input[n].split(' ').map(Number);
for(let i=x-1; i<x+9; i++){
for(let j=y-1; j<y+9; j++){
if(paper[i][j]===0){
paper[i][j]=1;
sum++;
}
}
}
}
console.log(sum);

View File

@ -0,0 +1,16 @@
const input = require("fs").readFileSync(0,"utf8").toString().split("\n");
let max_value=0, max_row=1, max_col=1;
for(let i=0; i<9; i++){
let n = input[i].split(' ').map(Number);
for(let j=0; j<9; j++){
if(max_value < n[j]){
max_value = n[j];
max_row = i+1;
max_col = j+1;
}
}
}
console.log(max_value);
console.log(max_row, max_col);

View File

@ -0,0 +1,13 @@
const input = require("fs").readFileSync(0,"utf8").toString().split("\n");
[n, m] = input[0].split(' ').map(Number);
let arr = []
for(let i=1; i<=n; i++){
let a = input[i].split(' ').map(Number);
let b = input[i+n].split(' ').map(Number);
arr[i-1]= a.map((v,idx) => v+b[idx]);
}
for(let i=0; i<n; i++){
console.log(...arr[i]);
}