108D - Basketball Team - CodeForces Solution


combinatorics math probabilities *1600

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>

using namespace std;

const int N = 1005;
int n, m, h, a[N], tot;
double s = 1;

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> m >> h;
  for(int i = 1; i <= m; ++i) cin >> a[i], tot += a[i];
  if(tot < n) return cout << -1, 0;
  for(int i = 1; i < n; ++i) {
    s = s * 1.0f * (double)((double)tot + 1 - a[h] - i) / (double)(tot - i);
  }
  cout << setprecision(6) << fixed << 1.0 - s;
}


Comments

Submit
0 Comments
More Questions

52A - 123-sequence
1543A - Exciting Bets
1714D - Color with Occurrences
215B - Olympic Medal
1445A - Array Rearrangment
1351A - A+B (Trial Problem)
935B - Fafa and the Gates
1291A - Even But Not Even
1269A - Equation
441A - Valera and Antique Items
1702C - Train and Queries
816B - Karen and Coffee
838D - Airplane Arrangements
148B - Escape
847G - University Classes
1110A - Parity
1215B - The Number of Products
604C - Alternative Thinking
1204C - Anna Svyatoslav and Maps
322A - Ciel and Dancing
1689B - Mystic Permutation
1711B - Party
1702D - Not a Cheap String
1714F - Build a Tree and That Is It
1703F - Yet Another Problem About Pairs Satisfying an Inequality
610A - Pasha and Stick
1200A - Hotelier
1091A - New Year and the Christmas Ornament
1352B - Same Parity Summands
1102A - Integer Sequence Dividing