結果

問題 No.759 悪くない忘年会にしような!
ユーザー finefine
提出日時 2018-12-27 23:01:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 2,104 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 175,480 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-04-09 03:08:10
合計ジャッジ時間 6,548 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 2 ms
6,948 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 2 ms
6,948 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,948 KB
testcase_15 AC 2 ms
6,948 KB
testcase_16 AC 2 ms
6,948 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 3 ms
6,948 KB
testcase_21 AC 2 ms
6,948 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,948 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,948 KB
testcase_28 AC 2 ms
6,948 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,948 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 7 ms
6,944 KB
testcase_34 AC 3 ms
6,948 KB
testcase_35 AC 5 ms
6,944 KB
testcase_36 AC 7 ms
6,948 KB
testcase_37 AC 3 ms
6,944 KB
testcase_38 AC 7 ms
6,944 KB
testcase_39 AC 3 ms
6,948 KB
testcase_40 AC 6 ms
6,944 KB
testcase_41 AC 7 ms
6,948 KB
testcase_42 AC 8 ms
6,944 KB
testcase_43 AC 8 ms
6,948 KB
testcase_44 AC 66 ms
6,948 KB
testcase_45 AC 67 ms
6,948 KB
testcase_46 AC 67 ms
7,040 KB
testcase_47 AC 68 ms
7,040 KB
testcase_48 AC 67 ms
7,168 KB
testcase_49 AC 8 ms
6,948 KB
testcase_50 AC 8 ms
6,944 KB
testcase_51 AC 8 ms
6,944 KB
testcase_52 AC 8 ms
6,944 KB
testcase_53 AC 67 ms
7,040 KB
testcase_54 AC 68 ms
7,040 KB
testcase_55 AC 67 ms
7,040 KB
testcase_56 AC 67 ms
7,168 KB
testcase_57 AC 68 ms
6,948 KB
testcase_58 AC 68 ms
7,168 KB
testcase_59 AC 67 ms
7,040 KB
testcase_60 AC 67 ms
7,168 KB
testcase_61 AC 67 ms
7,040 KB
testcase_62 AC 68 ms
7,168 KB
testcase_63 AC 189 ms
7,040 KB
testcase_64 AC 186 ms
6,948 KB
testcase_65 AC 61 ms
7,040 KB
testcase_66 AC 172 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

template <typename T>
struct SegmentTree {
	int n;
	vector<T> data;
	T INITIAL_VALUE;

	//使うときは、この2つを適宜変更する
	static T merge(T x, T y);
	void updateNode(int k, T x);

	SegmentTree(int size, T initial_value) {
		n = 1;
		INITIAL_VALUE = initial_value;
		while (n < size) n *= 2;
		data.resize(2 * n - 1, INITIAL_VALUE);
	}

	T getLeaf(int k) {
		return data[k + n - 1];
	}

	void update(int k, T x) {
		k += n - 1; //葉の節点
		updateNode(k, x);
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	//区間[a, b)に対するクエリに答える
	//k:節点番号, [l, r):節点に対応する区間
	T query(int a, int b, int k, int l, int r) {
		//[a, b)と[l, r)が交差しない場合
		if (r <= a || b <= l) return INITIAL_VALUE;
		//[a, b)が[l, r)を含む場合、節点の値
		if (a <= l && r <= b) return data[k];
		else {
			//二つの子をマージ
			T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return merge(vl, vr);
		}
	}

	//外から呼ぶ用
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

//使うときは以下2つを変更
template <typename T>
T SegmentTree<T>::merge(T x, T y) {
	return max(x, y);
}

template <typename T>
void SegmentTree<T>::updateNode(int k, T x) {
	data[k] = x;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> p(n), t(n), r(n), idxs(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i] >> t[i] >> r[i];
		idxs[i] = i;
	}

	auto comp = [&](const int i1, const int i2) {
		if (p[i1] != p[i2]) return p[i1] > p[i2];
		if (t[i1] != t[i2]) return t[i1] > t[i2];
		return r[i1] > r[i2];
	};
	sort(idxs.begin(), idxs.end(), comp);

	SegmentTree<ll> st(10001, -1);
	vector<int> ans(n, false);
	for (int i : idxs) {
		ll x = st.query(t[i], 10001);
		if (r[i] > x) {
			ans[i] = true;
			st.update(t[i], r[i]);
		}
	}

	for (int i = 0; i < n; i++) {
		if (ans[i]) cout << i + 1 << endl;
	}
	return 0;
}
0