Submission #537366

# Submission time Handle Problem Language Result Execution time Memory
537366 2022-03-15T03:46:02 Z 8e7 Treatment Project (JOI20_treatment) C++17
4 / 100
216 ms 33728 KB
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 100005
#define pii pair<ll, ll>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
const ll inf = 1LL<<60;
pii a[maxn];
ll cost[maxn], ans[4*maxn];
vector<pii> ev[4 * maxn];
vector<ll> del[4*maxn];
int main() {
	io
	int L, n;
	cin >> L >> n;
	vector<int> vx;
	for (int i = 1;i <= n;i++) {
		int t, l, r, c;
		cin >> t >> l >> r >> c;
		a[i] = {l, r};
		cost[i] = c;
		vx.push_back(l), vx.push_back(r), vx.push_back(l-1), vx.push_back(r+1);
	}
	sort(vx.begin(), vx.end());
	vx.resize(int(unique(vx.begin(), vx.end()) - vx.begin()));
	for (int i = 1;i <= n;i++) {
		a[i].ff = lower_bound(vx.begin(), vx.end(), a[i].ff) - vx.begin();
		a[i].ss = lower_bound(vx.begin(), vx.end(), a[i].ss) - vx.begin();
		ev[a[i].ff - 1].push_back({a[i].ss + 1, cost[i]});
	}
	if (vx[0] != 0 || vx.back() != L+1) {
		cout << -1 << endl;
		return 0;
	}
	multiset<ll> se;
	se.insert(0);
	del[1].push_back(0);	
	bool poss = 1;
	for (int i = 0;i < vx.size()-1;i++) {
		for (auto j:del[i]) {
			se.erase(se.find(j));
		}
		for (auto [t, c]:ev[i]) {
			if (se.size() == 0) {
				poss = 0;
				break;
			}
			ll val = c + *se.begin();
			del[t].push_back(val);
			se.insert(val);
		}
	}
	if (se.size() == 0) poss = 0;
	if (poss) cout << *se.begin() << "\n";
	else cout << -1 << endl;
}

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:53:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for (int i = 0;i < vx.size()-1;i++) {
      |                 ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 139 ms 30292 KB Output is correct
2 Correct 114 ms 30612 KB Output is correct
3 Correct 124 ms 31044 KB Output is correct
4 Correct 110 ms 31040 KB Output is correct
5 Correct 120 ms 28516 KB Output is correct
6 Correct 86 ms 29080 KB Output is correct
7 Correct 108 ms 30228 KB Output is correct
8 Correct 77 ms 27736 KB Output is correct
9 Correct 84 ms 28164 KB Output is correct
10 Correct 76 ms 28856 KB Output is correct
11 Correct 169 ms 33636 KB Output is correct
12 Correct 216 ms 33728 KB Output is correct
13 Correct 152 ms 32316 KB Output is correct
14 Correct 164 ms 32320 KB Output is correct
15 Correct 160 ms 32324 KB Output is correct
16 Correct 147 ms 32364 KB Output is correct
17 Correct 147 ms 31524 KB Output is correct
18 Correct 177 ms 32912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 19008 KB Output is correct
2 Incorrect 11 ms 19124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 19008 KB Output is correct
2 Incorrect 11 ms 19124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 139 ms 30292 KB Output is correct
2 Correct 114 ms 30612 KB Output is correct
3 Correct 124 ms 31044 KB Output is correct
4 Correct 110 ms 31040 KB Output is correct
5 Correct 120 ms 28516 KB Output is correct
6 Correct 86 ms 29080 KB Output is correct
7 Correct 108 ms 30228 KB Output is correct
8 Correct 77 ms 27736 KB Output is correct
9 Correct 84 ms 28164 KB Output is correct
10 Correct 76 ms 28856 KB Output is correct
11 Correct 169 ms 33636 KB Output is correct
12 Correct 216 ms 33728 KB Output is correct
13 Correct 152 ms 32316 KB Output is correct
14 Correct 164 ms 32320 KB Output is correct
15 Correct 160 ms 32324 KB Output is correct
16 Correct 147 ms 32364 KB Output is correct
17 Correct 147 ms 31524 KB Output is correct
18 Correct 177 ms 32912 KB Output is correct
19 Correct 13 ms 19008 KB Output is correct
20 Incorrect 11 ms 19124 KB Output isn't correct
21 Halted 0 ms 0 KB -