Submission #964311

# Submission time Handle Problem Language Result Execution time Memory
964311 2024-04-16T15:45:59 Z pcc Sure Bet (CEOI17_sure) C++17
100 / 100
91 ms 8392 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define int ll
#define ld long double

const int mxn = 2e5+10;

ll N;
ld arr[mxn],brr[mxn];

ld calc(int a,int b){
	if(a<=0||b<=0)return 0;
	return min(arr[a],brr[b])-a-b;
}

main(){
	scanf("%d",&N);
	for(int i = 1;i<=N;i++){
		double f;
		scanf("%lf",&f);
		arr[i] = f;
		scanf("%lf",&f);
		brr[i] = f;
	}
	sort(arr+1,arr+N+1,greater<ld>());
	sort(brr+1,brr+N+1,greater<ld>());
	for(int i = 1;i<=N*2;i++){
		arr[i] += arr[i-1];
		brr[i] += brr[i-1];
	}
	ld ans = 0;
	for(int i = 1;i<=N*2;i++){
		ll l = 0,r = min(i,N);
		while(l != r){
			int mid = (l+r+1)>>1;
			if(arr[mid]>brr[i-mid])r = mid-1;
			else l = mid;
		}
		ans = max(ans,min(arr[l],brr[i-l])-i);
		for(int j = -2;j<=2;j++){
			auto l = r+j;
			if(l<=i)ans = max(ans,calc(l,i-l));
		}
	}
	printf("%.4lf\n",(double)ans);
	return 0;
}

Compilation message

sure.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main(){
      | ^~~~
sure.cpp: In function 'int main()':
sure.cpp:24:10: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   24 |  scanf("%d",&N);
      |         ~^  ~~
      |          |  |
      |          |  long long int*
      |          int*
      |         %lld
sure.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d",&N);
      |  ~~~~~^~~~~~~~~
sure.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%lf",&f);
      |   ~~~~~^~~~~~~~~~
sure.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%lf",&f);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2548 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2548 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 87 ms 6484 KB Output is correct
18 Correct 91 ms 8040 KB Output is correct
19 Correct 85 ms 7832 KB Output is correct
20 Correct 79 ms 8052 KB Output is correct
21 Correct 80 ms 8392 KB Output is correct
22 Correct 77 ms 8024 KB Output is correct
23 Correct 78 ms 8044 KB Output is correct
24 Correct 77 ms 8028 KB Output is correct
25 Correct 83 ms 8040 KB Output is correct
26 Correct 79 ms 8272 KB Output is correct