Skip to content

Commit abc0ba7

Browse files
authored
[임동민] 61차 라이브코테 제출 (#505)
* 61차 1번 문제풀이 * 61차 2번 문제풀이 * 61차 3번 문제풀이
1 parent 18500d7 commit abc0ba7

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 T = input[0][0];
10+
let idx = 1;
11+
12+
const result = [];
13+
14+
for(let t=0; t<T; t++){
15+
const [N,M] = input[idx];
16+
idx += M + 1;
17+
18+
result.push(N-1);
19+
}
20+
21+
console.log(result.join('\n'));
22+
}
23+
24+
solution();

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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];
10+
const numArr = input[1];
11+
const testCase = input.slice(2);
12+
const result = [];
13+
const sum = new Array(N+1).fill(0);
14+
15+
for(let i=0; i<N; i++) {
16+
sum[i+1] = sum[i] + numArr[i];
17+
}
18+
19+
testCase.forEach(([start, end]) => {
20+
result.push(sum[end] - sum[start - 1]);
21+
})
22+
23+
console.log(result.join('\n'));
24+
}
25+
26+
solution();

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function solution(citations) {
2+
let result = 0;
3+
4+
for(let i=0; i<=citations.length; i++) {
5+
const count = citations.filter(e => e >= i).length;
6+
if(count >= i){
7+
result = i;
8+
}
9+
}
10+
return result;
11+
}

0 commit comments

Comments
 (0)