結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー ks2mks2m
提出日時 2021-06-11 21:54:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 473 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 73,988 KB
実行使用メモリ 47,544 KB
最終ジャッジ日時 2024-05-08 17:36:54
合計ジャッジ時間 15,994 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
40,200 KB
testcase_01 AC 108 ms
40,136 KB
testcase_02 AC 110 ms
39,864 KB
testcase_03 AC 212 ms
45,744 KB
testcase_04 AC 219 ms
45,788 KB
testcase_05 AC 219 ms
46,064 KB
testcase_06 AC 221 ms
45,504 KB
testcase_07 AC 220 ms
45,912 KB
testcase_08 AC 215 ms
45,724 KB
testcase_09 AC 219 ms
45,700 KB
testcase_10 AC 225 ms
45,872 KB
testcase_11 AC 198 ms
45,540 KB
testcase_12 AC 204 ms
45,720 KB
testcase_13 AC 201 ms
45,444 KB
testcase_14 AC 230 ms
46,336 KB
testcase_15 AC 241 ms
47,024 KB
testcase_16 AC 211 ms
45,688 KB
testcase_17 AC 193 ms
45,096 KB
testcase_18 AC 184 ms
43,680 KB
testcase_19 AC 185 ms
43,500 KB
testcase_20 AC 228 ms
46,144 KB
testcase_21 AC 197 ms
45,832 KB
testcase_22 AC 185 ms
44,344 KB
testcase_23 AC 243 ms
47,016 KB
testcase_24 AC 241 ms
46,400 KB
testcase_25 AC 250 ms
47,268 KB
testcase_26 AC 237 ms
47,288 KB
testcase_27 AC 239 ms
47,028 KB
testcase_28 AC 238 ms
47,144 KB
testcase_29 AC 233 ms
46,968 KB
testcase_30 AC 243 ms
47,048 KB
testcase_31 AC 236 ms
47,200 KB
testcase_32 AC 236 ms
46,288 KB
testcase_33 AC 425 ms
47,316 KB
testcase_34 AC 111 ms
40,840 KB
testcase_35 AC 117 ms
40,896 KB
testcase_36 AC 202 ms
45,508 KB
testcase_37 AC 202 ms
46,012 KB
testcase_38 AC 430 ms
47,496 KB
testcase_39 AC 435 ms
47,292 KB
testcase_40 AC 462 ms
47,420 KB
testcase_41 AC 438 ms
47,400 KB
testcase_42 AC 450 ms
47,408 KB
testcase_43 AC 440 ms
47,544 KB
testcase_44 AC 433 ms
47,228 KB
testcase_45 AC 442 ms
47,292 KB
testcase_46 AC 460 ms
47,308 KB
testcase_47 AC 473 ms
47,540 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