Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ์ต์ ๋์ฒด์ด๋
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- suspense ๋ณ๋ชฉํ์
- ์ค์ฝํ
- ๊ตฌ๋ฆํค
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- ์ฌ์ฉ์ฑ ๊ฐ์
- app router emotion
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- emtion app router
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- ๋ฐฑ์ค 2108 nodejs
- suspense ๋์์๋ฆฌ
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- suspense ๋น๋๊ธฐ
- emotion RSC
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- js ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 1339๋ฒ js
- next13 emotion
- js ์ค์ฝํ
- ์นด์นด์ค ์ฝํ
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- suspense react-query
- js
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
Archives
- Today
- Total
Lennon FE
[๋ฐฑ์ค 14612๋ฒ] ๊น์๋น - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
๐ฅ Algorithm/Baekjoon
[๋ฐฑ์ค 14612๋ฒ] ๊น์๋น - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon 2022. 5. 5. 02:01728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/14612
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
rl.on('line', function (line) {
input.push(line);
if (input.length === +input[0].split(' ')[0] + 1) {
rl.close();
}
}).on('close', function () {
const [N, M] = input.shift().split(' ').map(Number);
const commands = input.map((v) => v.split(' '));
const answer = [];
const result = [];
commands.forEach((ele) => {
if (ele[0] === 'order') {
result.push([ele[1], ele[2]].map(Number));
answer.push(result.map((v) => v[0]));
} else if (ele[0] === 'sort') {
if (result.length === 0) {
answer.push('sleep');
} else {
result.sort((a, b) => {
if (a[1] === b[1]) {
return a[0] - b[0];
} else {
return a[1] - b[1];
}
});
answer.push(result.map((v) => v[0]));
}
} else {
const resultFilterArr = result.map((v) => v[0]);
if (resultFilterArr.includes(+ele[1])) {
const idx = resultFilterArr.indexOf(+ele[1]);
result.splice(idx, 1);
}
if (result.length > 0) {
answer.push(result.map((v) => v[0]));
} else {
answer.push('sleep');
}
}
});
console.log(answer.map((v) => (Array.isArray(v) ? v.join(' ') : v)).join('\n'));
});
์ด ๋ฌธ์ ์ ํต์ฌ์ sort์ฒ๋ฆฌ์ด๋ค. ์๋ง ๊ทธ๊ฒ ๋๋ฌธ์ ์ ๋ต๋ฅ ์ด ๋ฎ์ ๊ฒ ๊ฐ๋ค.
๋น ๋ฐฐ์ด์์ sort ํค์๋๊ฐ ์งํ๋ ์ ์์ผ๋ฏ๋ก sleep์ ์ถ๋ ฅํด์ผํ๋ค!
๋ํ, sort๋ฅผ ์ธ ๋ ์ฃผ๋ฌธ ์๊ฐ์ด ๊ฐ์ผ๋ฉด ํ ์ด๋ธ ๋ฒํธ๊ฐ ์์ ๊ฒ๋ถํฐ ์ ๋ ฌํ๋ ๊ฒ๋ ๊ณ ๋ คํด์ผํ๋ค.
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 1912๋ฒ] ์ฐ์ํฉ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (1) | 2022.06.06 |
---|---|
[๋ฐฑ์ค 2607๋ฒ] ๋น์ทํ ๋จ์ด - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.07 |
[๋ฐฑ์ค 2108๋ฒ] ํต๊ณํ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.03 |
[๋ฐฑ์ค 1759๋ฒ] ์ํธ ๋ง๋ค๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.02 |
[๋ฐฑ์ค 14503๋ฒ] ๋ก๋ด์ฒญ์๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.30 |
Comments