답안 #964308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964308 2024-04-16T15:39:29 Z pcc Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 2396 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 = 1e5+10;

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

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;i++){
		arr[i] += arr[i-1];
		brr[i] += brr[i-1];
	}
	ld ans = 0;
	for(int i = 1;i<=N;i++){
		for(int j = 0;j<=i;j++){
			ans = max(ans,min(arr[j],brr[i-j])-i);
		}
		continue;
		ll l = 0,r = i;
		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);
		l++;
		for(int j = -2;j<=2;j++){
			auto l = r+j;
			if(l<=i)ans = max(ans,min(arr[l],brr[i-l])-i);
		}
	}
	cout<<fixed<<setprecision(4)<<ans<<'\n';
	return 0;
}

Compilation message

sure.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      | ^~~~
sure.cpp: In function 'int main()':
sure.cpp:19:10: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   19 |  scanf("%d",&N);
      |         ~^  ~~
      |          |  |
      |          |  long long int*
      |          int*
      |         %lld
sure.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d",&N);
      |  ~~~~~^~~~~~~~~
sure.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%lf",&f);
      |   ~~~~~^~~~~~~~~~
sure.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%lf",&f);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -