結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー kanTiramisukanTiramisu
提出日時 2020-01-19 17:26:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 5,000 ms
コード長 1,827 bytes
コンパイル時間 1,929 ms
コンパイル使用メモリ 164,320 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:56:37
合計ジャッジ時間 7,968 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 81 ms
6,944 KB
testcase_03 AC 155 ms
6,940 KB
testcase_04 AC 189 ms
6,944 KB
testcase_05 AC 190 ms
6,940 KB
testcase_06 AC 189 ms
6,940 KB
testcase_07 AC 213 ms
6,940 KB
testcase_08 AC 213 ms
6,940 KB
testcase_09 AC 215 ms
6,940 KB
testcase_10 AC 170 ms
6,944 KB
testcase_11 AC 180 ms
6,944 KB
testcase_12 AC 165 ms
6,940 KB
testcase_13 AC 196 ms
6,940 KB
testcase_14 AC 201 ms
6,944 KB
testcase_15 AC 181 ms
6,944 KB
testcase_16 AC 189 ms
6,940 KB
testcase_17 AC 191 ms
6,940 KB
testcase_18 AC 190 ms
6,944 KB
testcase_19 AC 213 ms
6,940 KB
testcase_20 AC 216 ms
6,944 KB
testcase_21 AC 216 ms
6,940 KB
testcase_22 AC 172 ms
6,944 KB
testcase_23 AC 181 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 6 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 36 ms
6,944 KB
testcase_29 AC 18 ms
6,940 KB
testcase_30 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
int n;
ll a[300000];

ll num(double v){
  ll t = 0;
  rep(i,n){
    t+=a[i]/v;
  }
  return t;
}

int main() {
  ll x = 1, y = 0, z = 0, k, h, ans = 0, w, sum = 1, Max = -1e9 - 1,
     cnt = 0, Min = 1e9 + 1;
  string s, t, u;
  bool ok = true;

  cin >> n;
  rep(i, n) { cin >> a[i]; }
  cin >> k;

  double l = 0, r = 1e11, m;
  rep(i, 100) { 
    m = (l + r) / 2; 
    if(num(m) >= k) l = m;
    else r = m;
  }
  cout << setprecision(12) << m << endl;
  return 0;
}
0