Submission #303054

# Submission time Handle Problem Language Result Execution time Memory
303054 2020-09-19T19:54:06 Z pedroslrey Sure Bet (CEOI17_sure) C++17
100 / 100
78 ms 2164 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);

	vector<double> xs, ys;
	for (int i = 0; i < n; ++i) {
		double x, y;
		scanf("%lf%lf", &x, &y);

		xs.push_back(x);
		ys.push_back(y);
	}

	sort(xs.rbegin(), xs.rend());
	sort(ys.rbegin(), ys.rend());

	double sum_x = 0, sum_y = 0;
	int stop_x = 0, stop_y = 0;
	double ans = 0;

	for (int i = 1; i <= 2*n; ++i) {
		if (sum_x < sum_y && stop_x < n)
			sum_x += xs[stop_x], ++stop_x;
		else if (sum_x >= sum_y && stop_y < n)
			sum_y += ys[stop_y], ++stop_y;

		ans = max(ans, min(sum_x, sum_y) - i);
	}

	printf("%.4f\n", ans);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |   scanf("%lf%lf", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 73 ms 2148 KB Output is correct
18 Correct 72 ms 2144 KB Output is correct
19 Correct 73 ms 2148 KB Output is correct
20 Correct 74 ms 2108 KB Output is correct
21 Correct 78 ms 2144 KB Output is correct
22 Correct 73 ms 2144 KB Output is correct
23 Correct 72 ms 2148 KB Output is correct
24 Correct 74 ms 2144 KB Output is correct
25 Correct 75 ms 2164 KB Output is correct
26 Correct 77 ms 2148 KB Output is correct