結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー ks2mks2m
提出日時 2024-02-23 21:57:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,106 ms / 2,500 ms
コード長 1,432 bytes
コンパイル時間 3,478 ms
コンパイル使用メモリ 79,160 KB
実行使用メモリ 80,576 KB
最終ジャッジ日時 2024-02-23 21:57:38
合計ジャッジ時間 32,097 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
54,140 KB
testcase_01 AC 56 ms
54,208 KB
testcase_02 AC 474 ms
66,972 KB
testcase_03 AC 251 ms
60,164 KB
testcase_04 AC 587 ms
67,032 KB
testcase_05 AC 517 ms
67,232 KB
testcase_06 AC 422 ms
60,960 KB
testcase_07 AC 510 ms
65,016 KB
testcase_08 AC 345 ms
60,336 KB
testcase_09 AC 893 ms
79,980 KB
testcase_10 AC 889 ms
79,808 KB
testcase_11 AC 853 ms
80,180 KB
testcase_12 AC 915 ms
79,804 KB
testcase_13 AC 888 ms
79,764 KB
testcase_14 AC 899 ms
80,576 KB
testcase_15 AC 864 ms
80,148 KB
testcase_16 AC 1,106 ms
79,940 KB
testcase_17 AC 1,083 ms
79,588 KB
testcase_18 AC 1,081 ms
79,728 KB
testcase_19 AC 1,097 ms
79,964 KB
testcase_20 AC 1,058 ms
78,888 KB
testcase_21 AC 1,060 ms
79,912 KB
testcase_22 AC 1,049 ms
78,024 KB
testcase_23 AC 939 ms
79,716 KB
testcase_24 AC 924 ms
79,808 KB
testcase_25 AC 928 ms
80,072 KB
testcase_26 AC 938 ms
79,888 KB
testcase_27 AC 919 ms
80,404 KB
testcase_28 AC 885 ms
79,868 KB
testcase_29 AC 947 ms
78,396 KB
testcase_30 AC 970 ms
80,256 KB
testcase_31 AC 923 ms
79,900 KB
testcase_32 AC 722 ms
77,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
//		int a = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		TreeSet<Obj> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.i = i;
			o.x = Integer.parseInt(sa[i]);
			set.add(o);
		}

		int t = Integer.parseInt(br.readLine());
		int[] l = new int[t];
		int[] r = new int[t];
		for (int i = 0; i < t; i++) {
			sa = br.readLine().split(" ");
			l[i] = Integer.parseInt(sa[0]);
			r[i] = Integer.parseInt(sa[1]) + 1;
		}
		br.close();

		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		Obj o1 = new Obj();
		Obj o2 = new Obj();
		for (int i = t - 1; i >= 0; i--) {
			o1.x = l[i];
			o2.x = r[i];
			Set<Obj> ss = set.subSet(o1, o2);
			for (Obj o : ss) {
				ans[o.i] = i + 1;
			}
			ss.clear();
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i : ans) {
			pw.println(i);
		}
		pw.flush();
	}

	static class Obj implements Comparable<Obj> {
		int i, x;

		@Override
		public int compareTo(Obj o) {
			if (x != o.x) {
				return x - o.x;
			}
			return i - o.i;
		}
	}
}
0