From 5b749cfe76924b956ac486a558d6aa1ba3a14a96 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Sun, 6 Jul 2025 17:49:27 +0900 Subject: [PATCH] 20250706 baekjoon --- code_study/Baekjoon/python/10816.py | 5 +++++ code_study/Baekjoon/ts/10816.ts | 7 +++++++ code_study/Baekjoon/ts/11773.ts | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 code_study/Baekjoon/python/10816.py create mode 100644 code_study/Baekjoon/ts/10816.ts create mode 100644 code_study/Baekjoon/ts/11773.ts diff --git a/code_study/Baekjoon/python/10816.py b/code_study/Baekjoon/python/10816.py new file mode 100644 index 0000000..bddfe60 --- /dev/null +++ b/code_study/Baekjoon/python/10816.py @@ -0,0 +1,5 @@ +from collections import Counter +input() +count = Counter(input().split()) +input() +print(' '.join(str(count[k]) for k in input().split())) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/10816.ts b/code_study/Baekjoon/ts/10816.ts new file mode 100644 index 0000000..f4bd673 --- /dev/null +++ b/code_study/Baekjoon/ts/10816.ts @@ -0,0 +1,7 @@ +const input: string[] = require("fs").readFileSync(0, "utf8").toString().trim().split("\n"); +let counter: Map = new Map(); +for(let n of input[1].split(" ").map(Number)){ + counter.set(n,(counter.get(n) || 0) + 1); +} +const result: string = input[3].split(" ").map(Number).map(n => counter.get(n) || 0).join(" "); +console.log(result); \ No newline at end of file diff --git a/code_study/Baekjoon/ts/11773.ts b/code_study/Baekjoon/ts/11773.ts new file mode 100644 index 0000000..ebf8ff3 --- /dev/null +++ b/code_study/Baekjoon/ts/11773.ts @@ -0,0 +1,14 @@ +export {} +const input:number[] = require("fs").readFileSync(0,"utf8").toString().trim().split('\n').map(Number); +let stack:number[] = []; +input.forEach((v,i) => { + if(i!==0){ + if(v===0){ + stack.pop(); + } + else { + stack.push(v); + } + } +}); +console.log(stack.reduce((acc,v) => acc + v, 0)); \ No newline at end of file