20250706 baekjoon

This commit is contained in:
songyc macbook 2025-07-06 17:49:27 +09:00
parent 9d16f1b6b2
commit 5b749cfe76
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,5 @@
from collections import Counter
input()
count = Counter(input().split())
input()
print(' '.join(str(count[k]) for k in input().split()))

View File

@ -0,0 +1,7 @@
const input: string[] = require("fs").readFileSync(0, "utf8").toString().trim().split("\n");
let counter: Map<number, number> = new Map<number, number>();
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);

View File

@ -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));