[백준] 13335번:트럭 (Java 자바)

[백준] 13335번:트럭 (Java 자바)

728x90

문제

https://www.acmicpc.net/problem/13335

풀이 및 소스코드

트럭과 다리를 모두 큐에 담아서 차근차근 구현해내면 된다!

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); // n : 트럭의 수 int w = Integer.parseInt(st.nextToken()); // w : 다리의 길이 int l = Integer.parseInt(st.nextToken()); // l : 다리의 최대 하중 st = new StringTokenizer(br.readLine()); Queue truck = new LinkedList<>(); Queue q = new LinkedList<>(); for (int i = 0; i < n; i++) { truck.add(Integer.parseInt(st.nextToken())); } for(int i=0;i

반응형

from http://jainn.tistory.com/308 by ccl(A) rewrite - 2021-11-01 15:27:28