답안 #61715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61715 2018-07-26T12:18:27 Z IvanC Sure Bet (CEOI17_sure) C++17
100 / 100
134 ms 16848 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;

double A[MAXN],B[MAXN],pref_A[MAXN],pref_B[MAXN];
int N;

double calcula(int x,int y){
	return min(pref_A[x],pref_B[y]) - (x + y);
}

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

int main(){

	double ans = 0.0;
	scanf("%d",&N);
	for(int i = 1;i<=N;i++){
		scanf("%lf %lf",&A[i],&B[i]);
	}
	sort(A+1,A+N+1,compara);
	sort(B+1,B+N+1,compara);
	for(int i = 1;i<=N;i++){
		pref_A[i] = pref_A[i-1] + A[i];
		pref_B[i] = pref_B[i-1] + B[i];
	}

	int opt = 0;
	for(int a = 0;a<=N;a++){
		while(opt + 1 <= N && calcula(a,opt) < calcula(a,opt+1)){
			opt++;
		}
		ans = max(ans,calcula(a,opt));
	}

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

	return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ~~~~~^~~~~~~~~
sure.cpp:22: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 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 3 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 3 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 3 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 3 ms 632 KB Output is correct
17 Correct 102 ms 3688 KB Output is correct
18 Correct 114 ms 5048 KB Output is correct
19 Correct 92 ms 6508 KB Output is correct
20 Correct 91 ms 7908 KB Output is correct
21 Correct 101 ms 9660 KB Output is correct
22 Correct 134 ms 10992 KB Output is correct
23 Correct 111 ms 12416 KB Output is correct
24 Correct 94 ms 13764 KB Output is correct
25 Correct 98 ms 15124 KB Output is correct
26 Correct 105 ms 16848 KB Output is correct