結果

問題 No.1675 Strange Minimum Query
ユーザー ks2mks2m
提出日時 2021-09-10 21:35:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,341 bytes
コンパイル時間 5,428 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 89,192 KB
最終ジャッジ日時 2023-09-02 16:14:08
合計ジャッジ時間 34,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
50,476 KB
testcase_01 AC 55 ms
52,248 KB
testcase_02 AC 55 ms
50,376 KB
testcase_03 AC 520 ms
63,616 KB
testcase_04 AC 562 ms
65,572 KB
testcase_05 AC 302 ms
59,992 KB
testcase_06 AC 555 ms
64,884 KB
testcase_07 AC 590 ms
65,760 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 889 ms
78,708 KB
testcase_14 AC 1,141 ms
89,192 KB
testcase_15 AC 1,136 ms
88,124 KB
testcase_16 AC 54 ms
50,352 KB
testcase_17 AC 398 ms
58,640 KB
testcase_18 AC 476 ms
64,128 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 962 ms
74,060 KB
testcase_23 AC 807 ms
64,328 KB
testcase_24 AC 814 ms
71,632 KB
testcase_25 AC 651 ms
63,624 KB
testcase_26 WA -
testcase_27 AC 843 ms
78,928 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 865 ms
66,968 KB
testcase_32 AC 1,054 ms
77,268 KB
testcase_33 AC 1,026 ms
76,396 KB
testcase_34 AC 1,085 ms
77,840 KB
testcase_35 AC 1,259 ms
81,236 KB
testcase_36 AC 1,253 ms
79,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
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 q = Integer.parseInt(sa[1]);
		PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> o2.b - o1.b);
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.l = Integer.parseInt(sa[0]) - 1;
			o.r = Integer.parseInt(sa[1]);
			o.b = Integer.parseInt(sa[2]);
			que.add(o);
		}
		br.close();

		int[] a = new int[n];
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			set.add(i);
		}
		Obj pre = null;
		while (!que.isEmpty()) {
			Obj o = que.poll();
			Set<Integer> ss = set.subSet(o.l, o.r);
			if (pre != null && o.b < pre.b && ss.isEmpty()) {
				System.out.println(-1);
				return;
			}
			for (int i : ss) {
				a[i] = o.b;
			}
			ss.clear();
			pre = o;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(a[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}

	static class Obj {
		int l, r, b;
	}
}
0