結果
| 問題 | No.2372 既視感 | 
| コンテスト | |
| ユーザー |  ks2m | 
| 提出日時 | 2023-07-07 21:31:12 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 273 ms / 2,000 ms | 
| コード長 | 1,140 bytes | 
| コンパイル時間 | 3,481 ms | 
| コンパイル使用メモリ | 77,980 KB | 
| 実行使用メモリ | 58,112 KB | 
| 最終ジャッジ日時 | 2024-07-21 17:13:48 | 
| 合計ジャッジ時間 | 9,627 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
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();
	}
}
            
            
            
        