64612023-12-02 15:34:38111Múzeumi őrökcpp17Elfogadva 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;
}

RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/03ms1828 KiB
2Elfogadva0/09ms5328 KiB
3Elfogadva1/13ms2424 KiB
4Elfogadva3/33ms2476 KiB
5Elfogadva2/23ms2700 KiB
6Elfogadva2/23ms2808 KiB
7Elfogadva2/23ms3068 KiB
8Elfogadva2/23ms3284 KiB
9Elfogadva2/23ms3504 KiB
10Elfogadva2/2112ms62376 KiB
11Elfogadva2/2111ms62360 KiB
12Elfogadva2/23ms4316 KiB
13Elfogadva2/24ms5276 KiB
14Elfogadva3/310ms8160 KiB
15Elfogadva3/310ms8560 KiB
16Elfogadva2/2112ms62380 KiB
17Elfogadva2/2104ms62368 KiB
18Elfogadva2/23ms4308 KiB
19Elfogadva2/22ms4316 KiB
20Elfogadva2/23ms4248 KiB
21Elfogadva2/23ms4460 KiB