Submission #2239463


Source Code Expand

//2018年  3月 21日 水曜日 17:38:41 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll C[2010][2010];

void C_init(int n) {
	n++;
	rep(i, 0, n) C[i][0] = 1;
	rep(i, 1, n) {
		rep(j, 1, i + 1) {
			C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
		}
	}
}

int N;
ll V[MAX_N];
ll F, T;
ll A, B, D;

void solve() {
	cin >> N >> F >> T;
	C_init(N);
	A = 1; B = 1;
	rep(i, 0, N) cin >> V[i];
	sort(V, V + N);

	for(int i = F; i <= T; i++) {
		ll S = accumulate(V + N - i, V + N, 0LL);
		ll a = V[N - i];
		int low = lower_bound(V, V + N, a) - V;
		int up = upper_bound(V, V + N, a) - V;
		// debug(i, S, low, up);
		// debug(N - i - up);
		ll c = C[up - low][up - (N - i)];
		if(S * B == i * A) {
			D += c;
		}
		else if(S * B > A * i) {
			D = c;
			A = S; B = i;
		}
	}
	cout << (double)A / B << "\n";
	cout << D << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Submission Info

Submission Time
Task D - Maximum Average Sets
User omochana2
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2730 Byte
Status AC
Exec Time 2 ms
Memory 2432 KB

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 2432 KB
subtask_1_1.txt AC 1 ms 384 KB
subtask_1_10.txt AC 2 ms 2432 KB
subtask_1_11.txt AC 2 ms 2432 KB
subtask_1_12.txt AC 1 ms 2432 KB
subtask_1_13.txt AC 2 ms 2432 KB
subtask_1_14.txt AC 2 ms 2432 KB
subtask_1_15.txt AC 2 ms 2432 KB
subtask_1_2.txt AC 1 ms 384 KB
subtask_1_3.txt AC 2 ms 2432 KB
subtask_1_4.txt AC 2 ms 2432 KB
subtask_1_5.txt AC 2 ms 2432 KB
subtask_1_6.txt AC 2 ms 2432 KB
subtask_1_7.txt AC 1 ms 2432 KB
subtask_1_8.txt AC 1 ms 2432 KB
subtask_1_9.txt AC 2 ms 2432 KB