結果

問題 No.1021 Children in Classrooms
ユーザー tentententen
提出日時 2022-08-04 13:18:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 1,619 bytes
コンパイル時間 2,247 ms
コンパイル使用メモリ 74,740 KB
実行使用メモリ 65,136 KB
最終ジャッジ日時 2023-10-12 10:43:15
合計ジャッジ時間 9,344 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,672 KB
testcase_01 AC 43 ms
49,400 KB
testcase_02 AC 43 ms
49,340 KB
testcase_03 AC 77 ms
51,544 KB
testcase_04 AC 80 ms
50,872 KB
testcase_05 AC 74 ms
50,660 KB
testcase_06 AC 81 ms
50,372 KB
testcase_07 AC 73 ms
50,380 KB
testcase_08 AC 81 ms
50,528 KB
testcase_09 AC 378 ms
63,488 KB
testcase_10 AC 380 ms
63,092 KB
testcase_11 AC 376 ms
65,136 KB
testcase_12 AC 373 ms
63,092 KB
testcase_13 AC 361 ms
63,160 KB
testcase_14 AC 383 ms
63,700 KB
testcase_15 AC 325 ms
60,960 KB
testcase_16 AC 322 ms
61,156 KB
testcase_17 AC 346 ms
59,352 KB
testcase_18 AC 351 ms
62,888 KB
testcase_19 AC 163 ms
55,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayDeque<Integer> line = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            line.addLast(sc.nextInt());
        }
        for (char c : sc.next().toCharArray()) {
            if (c == 'L') {
                line.addFirst(line.pollFirst() + line.pollFirst());
                line.addLast(0);
            } else {
                line.addLast(line.pollLast() + line.pollLast());
                line.addFirst(0);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(line.pollFirst());
        }
        System.out.println(sb);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0