-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10989 (수 정렬하기 3).js
75 lines (62 loc) · 1.38 KB
/
10989 (수 정렬하기 3).js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"use strict";
const ps = (function (process) {
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let lines = [];
let cursor = 0;
rl.on("line", function (line) {
lines.push(line);
});
return {
main(f) {
f()
.catch((err) => {
console.error(err);
process.exit(1);
})
.finally(() => {
rl.close();
});
},
readLine: async function readLine() {
return new Promise((resolve) => {
if (cursor < lines.length) {
resolve(lines[cursor++]);
} else {
setTimeout(() =>
readLine().then((line) => {
resolve(line);
})
);
}
});
},
async readArrayLine() {
const line = await this.readLine();
return line.split(/\s/).map((t) => parseInt(t));
},
};
})(process);
ps.main(async () => {
/* main logic goes here */
let [num] = await ps.readArrayLine()
let arr = [];
for (let i =0; i<num; i++){
arr.push(parseInt(await ps.readLine()));
}
let tempArr = Array.from({length:10000},()=>0);
let newArr = [];
arr.forEach(el=>{
tempArr[el]++;
})
tempArr.forEach((el, i)=>{
for(let j=0; j<el; j++)
newArr.push(i);
})
newArr.forEach(el=>{
console.log(el);
})
});