結果
問題 | No.2372 既視感 |
ユーザー | tenten |
提出日時 | 2023-07-11 14:01:54 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 3,528 bytes |
コンパイル時間 | 2,663 ms |
コンパイル使用メモリ | 96,580 KB |
実行使用メモリ | 52,720 KB |
最終ジャッジ日時 | 2024-09-13 04:27:15 |
合計ジャッジ時間 | 6,172 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
50,416 KB |
testcase_01 | AC | 53 ms
50,496 KB |
testcase_02 | AC | 52 ms
50,492 KB |
testcase_03 | AC | 52 ms
50,420 KB |
testcase_04 | AC | 52 ms
50,036 KB |
testcase_05 | AC | 52 ms
50,404 KB |
testcase_06 | AC | 52 ms
50,376 KB |
testcase_07 | AC | 52 ms
50,104 KB |
testcase_08 | AC | 87 ms
51,340 KB |
testcase_09 | AC | 87 ms
51,236 KB |
testcase_10 | AC | 103 ms
51,700 KB |
testcase_11 | AC | 98 ms
51,692 KB |
testcase_12 | AC | 54 ms
50,092 KB |
testcase_13 | AC | 99 ms
51,716 KB |
testcase_14 | AC | 60 ms
50,484 KB |
testcase_15 | AC | 84 ms
51,396 KB |
testcase_16 | AC | 91 ms
51,220 KB |
testcase_17 | AC | 62 ms
50,700 KB |
testcase_18 | AC | 58 ms
50,300 KB |
testcase_19 | AC | 56 ms
50,052 KB |
testcase_20 | AC | 56 ms
50,368 KB |
testcase_21 | AC | 56 ms
50,464 KB |
testcase_22 | AC | 61 ms
50,480 KB |
testcase_23 | AC | 111 ms
52,384 KB |
testcase_24 | AC | 105 ms
51,988 KB |
testcase_25 | AC | 113 ms
52,200 KB |
testcase_26 | AC | 112 ms
52,264 KB |
testcase_27 | AC | 107 ms
52,084 KB |
testcase_28 | AC | 132 ms
52,720 KB |
ソースコード
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(); int k = sc.nextInt(); int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); HashMap<String, Integer> counts = new HashMap<>(); ArrayDeque<String> deq = new ArrayDeque<>(); while (q-- > 0) { if (sc.nextInt() == 1) { String title = sc.next(); counts.put(title, counts.getOrDefault(title, 0) + 1); deq.add(title); if (deq.size() > n) { String x = deq.poll(); if (counts.get(x) == 1) { counts.remove(x); } else { counts.put(x, counts.get(x) - 1); } } } else { String[] titles = new String[6]; int[] times = new int[6]; for (int i = 0; i < 6; i++) { titles[i] = sc.next(); times[i] = sc.nextInt(); } int count = 0; int current = 0; for (int i = 0; i < 6; i++) { int score = times[i]; if (counts.containsKey(titles[i])) { score = Math.min(score, k); } if (score + current <= 60) { current += score; count++; } else { break; } } sb.append(count).append("\n"); for (int i = 0; i < count; i++) { deq.add(titles[i]); counts.put(titles[i], counts.getOrDefault(titles[i], 0) + 1); } while (deq.size() > n) { String x = deq.poll(); if (counts.get(x) == 1) { counts.remove(x); } else { counts.put(x, counts.get(x) - 1); } } } } 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(); } }