Submission #153404

# Submission time Handle Problem Language Result Execution time Memory
153404 2019-09-14T06:01:27 Z junodeveloper Sure Bet (CEOI17_sure) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n;
double a[100010],b[100010];
int main() {
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++)scanf("%lf%lf",a+i,b+i);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++) a[i+1]+=a[i],b[i+1]+=b[i];
	int k;
	double ans=0;
	for(k=1;k<=n+n;k++) {
		int lo=max(0,k-n),hi=min(n,k);
		while(lo<hi) {
			int mid=(lo+hi+1)/2;
			if(a[n]-a[n-mid]<b[n]-b[n-(k-mid)]) lo=mid;
			else hi=mid-1;
		}
		ans=max(ans,a[n]-a[n-lo]-k);
		if(lo<min(n,k)) ans=max(ans,b[n]-b[n-(k-lo-1)]-k);
	}
	printf("%.4f",ans);
	return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
sure.cpp:16:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++)scanf("%lf%lf",a+i,b+i);
                   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -