답안 #103831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103831 2019-04-02T21:21:29 Z luciocf Sure Bet (CEOI17_sure) C++14
100 / 100
102 ms 5120 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+10;

int n;

double a[maxn], b[maxn];
double s[2][maxn];

int busca(int m, bool q)
{
	int ini, fim, ans = 0;

	if (m > n) ini = m-n, fim = n;
	else ini = 1, fim = m;

	while (ini <= fim)
	{
		int mid = (ini+fim)>>1;

		if (s[q][mid] <= s[!q][m-mid]) ans = mid, ini = mid+1;
		else fim = mid-1;
	}

	return ans;
}

bool comp(double a, double b) {return a > b;}

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

	for (int i = 1; i <= n; i++)
		scanf("%lf %lf", &a[i], &b[i]);

	sort(a+1, a+n+1, comp);
	sort(b+1, b+n+1, comp);

	for (int i = 1; i <= n; i++)
	{
		s[0][i] = s[0][i-1]+a[i];
		s[1][i] = s[1][i-1]+b[i];
	}

	double ans = 0.00;

	for (int i = 1; i <= 2*n; i++)
		ans = max({ans, s[0][busca(i, 0)]-(double)i, s[1][busca(i, 1)]-(double)i});

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

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
sure.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf", &a[i], &b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 356 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 356 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 88 ms 4864 KB Output is correct
18 Correct 88 ms 4836 KB Output is correct
19 Correct 81 ms 4864 KB Output is correct
20 Correct 86 ms 4856 KB Output is correct
21 Correct 81 ms 5120 KB Output is correct
22 Correct 78 ms 4856 KB Output is correct
23 Correct 102 ms 4728 KB Output is correct
24 Correct 79 ms 4856 KB Output is correct
25 Correct 87 ms 4780 KB Output is correct
26 Correct 84 ms 5112 KB Output is correct