結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー ks2mks2m
提出日時 2021-06-11 21:54:44
言語 Java19
(openjdk 21)
結果
AC  
実行時間 457 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 3,224 ms
コンパイル使用メモリ 70,932 KB
実行使用メモリ 61,984 KB
最終ジャッジ日時 2023-08-21 12:17:39
合計ジャッジ時間 17,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,092 KB
testcase_01 AC 122 ms
55,816 KB
testcase_02 AC 123 ms
55,944 KB
testcase_03 AC 217 ms
57,068 KB
testcase_04 AC 226 ms
58,928 KB
testcase_05 AC 212 ms
58,984 KB
testcase_06 AC 226 ms
58,748 KB
testcase_07 AC 226 ms
59,192 KB
testcase_08 AC 220 ms
58,800 KB
testcase_09 AC 215 ms
58,852 KB
testcase_10 AC 228 ms
58,976 KB
testcase_11 AC 218 ms
59,132 KB
testcase_12 AC 215 ms
59,244 KB
testcase_13 AC 208 ms
58,864 KB
testcase_14 AC 234 ms
59,204 KB
testcase_15 AC 240 ms
59,328 KB
testcase_16 AC 220 ms
59,356 KB
testcase_17 AC 202 ms
58,608 KB
testcase_18 AC 195 ms
58,320 KB
testcase_19 AC 192 ms
58,416 KB
testcase_20 AC 224 ms
58,700 KB
testcase_21 AC 206 ms
59,108 KB
testcase_22 AC 195 ms
58,596 KB
testcase_23 AC 239 ms
59,480 KB
testcase_24 AC 237 ms
59,184 KB
testcase_25 AC 243 ms
59,740 KB
testcase_26 AC 237 ms
59,632 KB
testcase_27 AC 239 ms
60,048 KB
testcase_28 AC 238 ms
59,200 KB
testcase_29 AC 243 ms
59,568 KB
testcase_30 AC 246 ms
60,176 KB
testcase_31 AC 238 ms
59,388 KB
testcase_32 AC 237 ms
59,364 KB
testcase_33 AC 442 ms
61,984 KB
testcase_34 AC 121 ms
55,760 KB
testcase_35 AC 121 ms
55,760 KB
testcase_36 AC 206 ms
57,468 KB
testcase_37 AC 206 ms
58,880 KB
testcase_38 AC 446 ms
60,144 KB
testcase_39 AC 445 ms
60,576 KB
testcase_40 AC 457 ms
60,204 KB
testcase_41 AC 445 ms
60,160 KB
testcase_42 AC 450 ms
60,128 KB
testcase_43 AC 441 ms
59,964 KB
testcase_44 AC 442 ms
60,388 KB
testcase_45 AC 455 ms
60,100 KB
testcase_46 AC 450 ms
59,860 KB
testcase_47 AC 442 ms
60,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 m = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		int nm = n * m;
		for (int i = 0; i < nm; i++) {
			if (a[i % n] == b[i % m]) {
				System.out.println(i + 1);
				return;
			}
		}
		System.out.println(-1);
	}
}
0