Submission #547056

# Submission time Handle Problem Language Result Execution time Memory
547056 2022-04-09T09:59:41 Z d2k05 Fuel Station (NOI20_fuelstation) C++14
0 / 100
231 ms 12792 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 1e6 + 5;

int n, d;
pair <int, pair <int, int> > a[N];

double mx(double f) {
	double cur = f, now = 0;
	for (int i = 1; i <= n; ++i) {
		if (cur >= a[i].first - now) {
			cur -= a[i].first - now;
			now = a[i].first;
		} 
		else 
			return now + cur;
		if (f <= a[i].second.second)
			cur += a[i].second.first;
	}
	return min(d * 1.0, now + cur);
}

int main() {
	ios :: sync_with_stdio(0), cin.tie(0);
	cin >> n >> d;
	for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second.first >> a[i].second.second;
	sort(a + 1, a + 1 + n);
	double lb = 0, rb = d;
	for (int i = 0; i < 100; ++i) {
		double md1 = lb + (rb - lb) / 3;
		double md2 = rb - (rb - lb) / 3;
		if (md2 < md1) break;
		if (mx(md1) > mx(md2)) {
			rb = md2;
		} else if (mx(md1) < mx(md2)) {
			lb = md1;
		} else {
			rb = md1;
		}
	}
	cout << lb;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 213 ms 12244 KB Output is correct
2 Correct 179 ms 12272 KB Output is correct
3 Correct 231 ms 12156 KB Output is correct
4 Correct 199 ms 12248 KB Output is correct
5 Incorrect 172 ms 12792 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 9 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 9 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -