結果

問題 No.2372 既視感
ユーザー ks2mks2m
提出日時 2023-07-07 21:31:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,140 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 74,596 KB
実行使用メモリ 60,036 KB
最終ジャッジ日時 2023-09-28 22:28:38
合計ジャッジ時間 8,367 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,004 KB
testcase_01 AC 127 ms
55,684 KB
testcase_02 AC 122 ms
55,700 KB
testcase_03 AC 121 ms
55,876 KB
testcase_04 AC 120 ms
55,832 KB
testcase_05 AC 123 ms
55,968 KB
testcase_06 AC 121 ms
55,800 KB
testcase_07 AC 120 ms
56,084 KB
testcase_08 AC 206 ms
59,640 KB
testcase_09 AC 192 ms
59,768 KB
testcase_10 AC 206 ms
59,268 KB
testcase_11 AC 199 ms
59,524 KB
testcase_12 AC 141 ms
56,072 KB
testcase_13 AC 205 ms
59,724 KB
testcase_14 AC 176 ms
56,484 KB
testcase_15 AC 190 ms
58,992 KB
testcase_16 AC 192 ms
58,608 KB
testcase_17 AC 177 ms
56,612 KB
testcase_18 AC 173 ms
56,732 KB
testcase_19 AC 156 ms
56,260 KB
testcase_20 AC 166 ms
56,952 KB
testcase_21 AC 147 ms
56,104 KB
testcase_22 AC 176 ms
56,960 KB
testcase_23 AC 235 ms
59,212 KB
testcase_24 AC 230 ms
59,724 KB
testcase_25 AC 226 ms
59,912 KB
testcase_26 AC 210 ms
60,036 KB
testcase_27 AC 236 ms
59,668 KB
testcase_28 AC 228 ms
59,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		List<String> list = new ArrayList<>();
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			int tp = sc.nextInt();
			if (tp == 1) {
				list.add(sc.next());
			} else {
				int[] t = new int[6];
				String[] d = new String[6];
				for (int j = 0; j < 6; j++) {
					d[j] = sc.next();
					t[j] = sc.nextInt();
				}
				int sum = 0;
				int m = list.size();
				int ans = 6;
				for (int j = 0; j < 6; j++) {
					boolean flg = false;
					for (int j2 = Math.max(m - n, 0); j2 < m; j2++) {
						if (list.get(j2).equals(d[j])) {
							flg = true;
							break;
						}
					}
					if (flg) {
						sum += Math.min(t[j], k);
					} else {
						sum += t[j];
					}
					if (sum > 60) {
						ans = j;
						break;
					}
					list.add(d[j]);
				}
				pw.println(ans);
			}
		}
		pw.flush();
		sc.close();
	}
}
0