64612023-12-02 15:34:38111Múzeumi őrökcpp17Accepted 40/40112ms62380 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double

#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef CB
	freopen("be2.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N, S, E;
	cin >> N >> S >> E;
	vector<vector<array<int, 3>>> v(E + 1);
	for (int i = 0; i < N; i++) {
		int s, e, c;
		cin >> s >> e >> c;
		v[s].push_back({e, c, i});
	}
	multimap<int, pii> m;
	vector<pii> w;
	m.insert({S, {0, -1}});
	for (int i = S; i <= E; i++) {
		if (m.lower_bound(i) == m.end()) {
			cout << -1 << endl;
			return 0;
		}
		auto [c, j] = m.lower_bound(i)->second;
		for (auto a : v[i]) {
			int k = w.size();
			w.push_back({a[2], j});
			auto it = m.insert({a[0] + 1, {c + a[1], k}});
			while (it->second.first <= prev(it)->second.first) {
				m.erase(prev(it));
			}
			while (next(it) != m.end() && next(it)->second.first <= it->second.first) {
				it = m.erase(it);
			}
		}
	}
	if (m.lower_bound(E + 1) == m.end()) {
		cout << -1 << endl;
		return 0;
	}
	auto [c, j] = m.lower_bound(E + 1)->second;
	cout << c << endl;
	vector<int> ans;
	while (j != -1) {
		ans.push_back(w[j].first);
		j = w[j].second;
	}
	sort(ans.begin(), ans.end());
	cout << ans.size();
	for (int i : ans) {
		cout << ' ' << i + 1;
	}
	cout << endl;
	return 0;
}

SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted0/09ms5328 KiB
3Accepted1/13ms2424 KiB
4Accepted3/33ms2476 KiB
5Accepted2/23ms2700 KiB
6Accepted2/23ms2808 KiB
7Accepted2/23ms3068 KiB
8Accepted2/23ms3284 KiB
9Accepted2/23ms3504 KiB
10Accepted2/2112ms62376 KiB
11Accepted2/2111ms62360 KiB
12Accepted2/23ms4316 KiB
13Accepted2/24ms5276 KiB
14Accepted3/310ms8160 KiB
15Accepted3/310ms8560 KiB
16Accepted2/2112ms62380 KiB
17Accepted2/2104ms62368 KiB
18Accepted2/23ms4308 KiB
19Accepted2/22ms4316 KiB
20Accepted2/23ms4248 KiB
21Accepted2/23ms4460 KiB