From a77d43e010f0afb866476d161df90112c982d10c Mon Sep 17 00:00:00 2001 From: GeonHui2 <022686@naver.com> Date: Sat, 13 Jan 2024 17:32:35 +0900 Subject: [PATCH] =?UTF-8?q?Create=201940.=20=EA=B0=80=EB=9E=8F!=20RC?= =?UTF-8?q?=EC=B9=B4!.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...260\200\353\236\217! RC\354\271\264!.java" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "\354\235\264\352\261\264\355\235\254/SWexpertacademy/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" diff --git "a/\354\235\264\352\261\264\355\235\254/SWexpertacademy/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" "b/\354\235\264\352\261\264\355\235\254/SWexpertacademy/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" new file mode 100644 index 00000000..4de31a66 --- /dev/null +++ "b/\354\235\264\352\261\264\355\235\254/SWexpertacademy/D2/1940. \352\260\200\353\236\217! RC\354\271\264!.java" @@ -0,0 +1,32 @@ +import java.util.Scanner; +import java.io.FileInputStream; + +class Solution +{ + public static void main(String args[]) throws Exception + { + Scanner sc = new Scanner(System.in); + int T; + T=sc.nextInt(); + + for(int test_case = 1; test_case <= T; test_case++) + { + int result = 0; + int speed = 0; + int N = sc.nextInt(); + + for (int i = 0; i < N; i++) { + int command = sc.nextInt(); + + if (command == 1) { + speed += sc.nextInt(); + } else if (command == 2) { + speed -= sc.nextInt(); + speed = (speed > 0) ? speed : 0; + } + result += speed; + } + System.out.printf("#%d %d\n", test_case, result); + } + } +}