fork download
  1. #include "bits/stdc++.h"
  2.  
  3. #define ll long long int
  4. #define vll vector<ll>
  5. #define vi vector<int>
  6. #define pll pair<long long, long long>
  7. #define vpll vector < pair<long long,long long> >
  8. #define all(c) c.begin(),c.end()
  9. #define pb push_back
  10. #define nl cout << '\n'
  11. #define ff first
  12. #define ss second
  13. #define mod 998244353
  14. #define inf 1000000000000000001
  15.  
  16. #define rep(i, n) for(int i = 0; i < n; ++i)
  17. #define repA(i, a, n) for(int i = a; i <= n; ++i)
  18. #define repD(i, a, n) for(int i = a; i >= n; --i)
  19.  
  20. using namespace std;
  21.  
  22. void solve(){
  23. ll n, m, h;
  24. cin >> n >> m >> h;
  25. vll v(m);
  26. rep(i, m){
  27. cin >> v[i];
  28. }
  29.  
  30. ll tot = 0;
  31. for(auto i: v)
  32. tot += i;
  33. if (tot < n)
  34. {
  35. cout << -1;
  36. return;
  37. }
  38. if (v[h] == 1 or n == 1)
  39. {
  40. cout << 0;
  41. return;
  42. }
  43. cout << fixed << setprecision(20) << (n-1) / (double)(tot - 1);
  44. }
  45.  
  46. int main(){
  47. // ios::sync_with_stdio(0);
  48. // cin.tie(0); cout.tie(0);
  49.  
  50. int t = 1, tmp = 0;
  51. // cin >> t;
  52. while(t--){
  53. // cout << "Case #" << ++tmp << ": ";
  54. solve();
  55. if(t) cout << "\n";
  56. }
  57. cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  58. return 0;
  59. }
Success #stdin #stdout #stderr 0s 5284KB
stdin
3 2 1
2 2
stdout
0.66666666666666662966
stderr
Time : 0.004456s