목록문제 (388)
sm 기술 블로그
import java.util.*; import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int N = Integer.parseInt(br.readLine()); Stack stack = new Stack(); for (int i = 0; i < N; i++) { String S = ""; int num = 0; String[] tmp = br.readLine().split(" "); if(tmp..
import sys input = sys.stdin.readline N = int(input()) stack = [] result = "" for _ in range(N): S = input() tmp = S.split() num = 0 if len(tmp) == 1: S = tmp[0] elif len(tmp) == 2: S = tmp[0] num = int(tmp[1]) if S == "push": stack.append(num) elif S == "size": result += str(len(stack)) + "\n" elif S == "empty": if len(stack) == 0: result += str("1") + "\n" else: result += str("0") + "\n" elif ..
import java.util.*; import java.io.*; import java.math.BigInteger; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); BigInteger result = new BigInteger("0"); int start = 0; long[] road = new long[N - 1]; long[] city = new long[N]; String[] roadTmp = br.readLin..
import sys input = sys.stdin.readline N = int(input()) road = list(map(int, input().split())) city = list(map(int, input().split())) result = 0 start = 0 for i in range(1, len(city)): if (i == len(city)-1): for j in range(start, len(road)): result += road[j] * city[start] elif (city[start] > city[i]): for j in range(start, i): result += road[j] * city[start] start = i else: continue print(result..