Submission #1181862


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
 
 
#define MAX 52
 
int n;
int a;
int b;
 
long long int v[MAX];
 
long long int dp[MAX][MAX];
 
 
struct fraction{
	long long int A;
	long long int B;
	long long int way;
	fraction(long long int a_, long long int b_, long long int way_){
		A = a_;
		B = b_;
		way = way_;
	}
};
bool big(fraction a, fraction b){
	return a.A*b.B > b.A*a.B;
}
bool eq(fraction a, fraction b){
	return a.A*b.B == b.A*a.B;
}
map<long long int, int> mp;
map<long long int, int> use;
int main(){
	dp[0][0] = 1;
	for (int i = 0; i <50; i++){
		for (int j = 0; j <= i; j++){
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] += dp[i][j];
		}
	}
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++){
		long long int A;
		scanf("%lld", &A);
		v[i] = A;
		mp[v[i]]++;
	}
	sort(v, v + n);
	reverse(v, v + n);
	fraction cur(0, 0, 1);
	fraction maxt(0, 1, 0);
	for (int i = 0; i < n; i++){
		cur.A += v[i];
		cur.B++;
		use[v[i]]++;
		if (cur.B >= a&&cur.B <= b){
			if (big(maxt, cur)){
				continue;
			}
			if (eq(maxt, cur)){
 
			}
			else{
				maxt = cur;
				maxt.way = 0;
			}
			maxt.way += dp[mp[v[i]]][use[v[i]]];
		}
	}
	double f = (long double)(maxt.A) / (long double)(maxt.B);
	printf("%.16f\n", f);
	printf("%lld\n", maxt.way);
	return 0;
}

Submission Info

Submission Time
Task D - Maximum Average Sets
User Kmcode
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1341 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:45:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &A);
                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 1 ms 256 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_2.txt AC 1 ms 256 KB
subtask_1_3.txt AC 1 ms 256 KB
subtask_1_4.txt AC 1 ms 256 KB
subtask_1_5.txt AC 1 ms 256 KB
subtask_1_6.txt AC 1 ms 256 KB
subtask_1_7.txt AC 1 ms 256 KB
subtask_1_8.txt AC 1 ms 256 KB
subtask_1_9.txt AC 1 ms 256 KB