From 94fde6eadbf834efe5be8b60a2afe77a61c2572c Mon Sep 17 00:00:00 2001 From: ramrami-B <21801034@handong.ac.kr> Date: Wed, 17 Jan 2024 00:28:58 +0900 Subject: [PATCH] =?UTF-8?q?Create=201940RC=EC=B9=B4.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1940RC\354\271\264.java" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "\353\260\261\355\225\230\353\236\214/1940RC\354\271\264.java" diff --git "a/\353\260\261\355\225\230\353\236\214/1940RC\354\271\264.java" "b/\353\260\261\355\225\230\353\236\214/1940RC\354\271\264.java" new file mode 100644 index 00000000..70ea3891 --- /dev/null +++ "b/\353\260\261\355\225\230\353\236\214/1940RC\354\271\264.java" @@ -0,0 +1,38 @@ +import java.util.*; + +public class Solution { + public static void main(String args[]) throws Exception { + Scanner sc = new Scanner(System.in); + + int T = sc.nextInt(); + + for(int t=1; t < T+1; t++) { + int answer = 0; + int command = 0; + int accel = 0; + int speed = 0; + + int N = sc.nextInt(); + + for(int i = 0; i < N; i++) { + command = sc.nextInt(); + + if(command == 1 || command == 2) + accel = sc.nextInt(); + + if(command == 1) + speed += accel; + if(command == 2) + if(speed < accel) + speed = 0; + else + speed -= accel; + + answer += speed; + } + + System.out.println("#" + t + " " + answer); + } + sc.close(); + } +} \ No newline at end of file