結果

問題 No.714 回転寿司屋のシミュレート
ユーザー tentententen
提出日時 2023-02-15 16:41:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 2,743 bytes
コンパイル時間 3,400 ms
コンパイル使用メモリ 93,356 KB
実行使用メモリ 53,164 KB
最終ジャッジ日時 2023-09-25 01:21:44
合計ジャッジ時間 9,160 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
49,544 KB
testcase_01 AC 47 ms
49,552 KB
testcase_02 AC 51 ms
49,356 KB
testcase_03 AC 57 ms
51,000 KB
testcase_04 AC 88 ms
51,844 KB
testcase_05 AC 110 ms
52,192 KB
testcase_06 AC 121 ms
53,060 KB
testcase_07 AC 144 ms
53,164 KB
testcase_08 AC 155 ms
52,772 KB
testcase_09 AC 131 ms
52,652 KB
testcase_10 AC 126 ms
52,408 KB
testcase_11 AC 123 ms
52,280 KB
testcase_12 AC 123 ms
52,656 KB
testcase_13 AC 120 ms
51,936 KB
testcase_14 AC 118 ms
52,380 KB
testcase_15 AC 107 ms
51,888 KB
testcase_16 AC 111 ms
52,236 KB
testcase_17 AC 124 ms
53,092 KB
testcase_18 AC 123 ms
52,644 KB
testcase_19 AC 102 ms
51,840 KB
testcase_20 AC 118 ms
52,544 KB
testcase_21 AC 99 ms
51,780 KB
testcase_22 AC 93 ms
50,460 KB
testcase_23 AC 96 ms
51,508 KB
testcase_24 AC 92 ms
51,600 KB
testcase_25 AC 94 ms
50,372 KB
testcase_26 AC 83 ms
51,300 KB
testcase_27 AC 99 ms
51,420 KB
testcase_28 AC 90 ms
51,820 KB
testcase_29 AC 87 ms
51,656 KB
testcase_30 AC 46 ms
49,492 KB
testcase_31 AC 49 ms
49,212 KB
testcase_32 AC 47 ms
49,260 KB
testcase_33 AC 45 ms
49,196 KB
testcase_34 AC 45 ms
49,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        TreeMap<Integer, HashMap<String, Integer>> place = new TreeMap<>();
        while (n-- > 0) {
            int type = sc.nextInt();
            if (type == 0) {
                int k = sc.nextInt();
                int x = sc.nextInt();
                HashMap<String, Integer> tmp = new HashMap<>();
                for (int i = 0; i < x; i++) {
                    String menu = sc.next();
                    tmp.put(menu, tmp.getOrDefault(menu, 0) + 1);
                }
                place.put(k, tmp);
            } else if (type == 1) {
                String menu = sc.next();
                int ans = -1;
                for (int x : place.keySet()) {
                    if (place.get(x).containsKey(menu)) {
                        if (place.get(x).get(menu) == 1) {
                            place.get(x).remove(menu);
                        } else {
                            place.get(x).put(menu, place.get(x).get(menu) - 1);
                        }
                        ans = x;
                        break;
                    }
                }
                sb.append(ans).append("\n");
            } else {
                place.remove(sc.nextInt());
            }
        }
        System.out.print(sb);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0