Submission #535399

# Submission time Handle Problem Language Result Execution time Memory
535399 2022-03-10T08:27:33 Z Asymmetry Sure Bet (CEOI17_sure) C++17
100 / 100
64 ms 3524 KB
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif

int n;
double odp;
double wyn[2];

int main() {
	scanf("%d", &n);
	vector<vector<double>> v(2, vector<double>(n));
	for (int i = 0; i < n; ++i) {
		scanf("%lf%lf", &v[0][i], &v[1][i]);
	}
	sort(v[0].begin(), v[0].end());
	sort(v[1].begin(), v[1].end());
	reverse(v[0].begin(), v[0].end());
	reverse(v[1].begin(), v[1].end());
	int p[2] = {0, 0};
	while (true) {
		if (wyn[0] < wyn[1]) {
			if (p[0] == n) {
				break;
			}
			wyn[0] += v[0][p[0]++];
			odp = max(odp, min(wyn[0], wyn[1]) - p[0] - p[1]);
		}
		else {
			if (p[1] == n) {
				break;
			}
			wyn[1] += v[1][p[1]++];
			odp = max(odp, min(wyn[0], wyn[1]) - p[0] - p[1]);
		}
	}
	printf("%.4lf\n", odp);
	return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%lf%lf", &v[0][i], &v[1][i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 57 ms 3232 KB Output is correct
18 Correct 59 ms 3140 KB Output is correct
19 Correct 58 ms 3128 KB Output is correct
20 Correct 58 ms 3236 KB Output is correct
21 Correct 62 ms 3516 KB Output is correct
22 Correct 58 ms 3256 KB Output is correct
23 Correct 63 ms 3124 KB Output is correct
24 Correct 59 ms 3228 KB Output is correct
25 Correct 60 ms 3148 KB Output is correct
26 Correct 64 ms 3524 KB Output is correct