diff --git a/code_study/Baekjoon/python/2010.py b/code_study/Baekjoon/python/2010.py new file mode 100644 index 0000000..7916673 --- /dev/null +++ b/code_study/Baekjoon/python/2010.py @@ -0,0 +1,10 @@ +import sys +input = sys.stdin.readline +ans = 0 +for i in range(int(input())) : + if i == 0 : + ans += int(input()) + else : + ans = ans - 1 + int(input()) + +print(ans) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/2143.ts b/code_study/Baekjoon/ts/2143.ts new file mode 100644 index 0000000..30887c9 --- /dev/null +++ b/code_study/Baekjoon/ts/2143.ts @@ -0,0 +1,60 @@ +export {}; +const input = require("fs").readFileSync(0).toString().trim().split('\n'); + +const T: number = Number(input[0]); +const [n, m]: number[] = [Number(input[1]), Number(input[3])]; +const A: number[] = input[2].split(" ").map(Number); +const B: number[] = input[4].split(" ").map(Number); + +let sumA: number[] = []; +for(let i=0; i a - b); +sumB.sort((a,b) => b - a); +const [N, M]: number[] = [sumA.length, sumB.length]; + +let [ptA, ptB]: number[] = [0, 0]; +let ans: number = 0; + +while (ptA < N && ptB < M) { + const curr: number = sumA[ptA] + sumB[ptB]; + + if(curr !== T ) { + if(T > curr) ptA++; + else if(T < curr) ptB++; + continue; + } + + let cntA: number = 0; + let valA: number = sumA[ptA]; + while(ptA < N && sumA[ptA] === valA) { + cntA++; + ptA++; + } + + let cntB: number = 0; + let valB: number = sumB[ptB]; + while(ptB < M && sumB[ptB] === valB) { + cntB++; + ptB++; + } + + ans += cntA*cntB; +} + +console.log(ans); \ No newline at end of file