結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー Zu_rinZu_rin
提出日時 2020-05-09 01:42:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 78,672 KB
実行使用メモリ 9,212 KB
最終ジャッジ日時 2023-09-17 06:22:46
合計ジャッジ時間 10,272 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
4,876 KB
testcase_01 WA -
testcase_02 AC 67 ms
4,376 KB
testcase_03 AC 126 ms
4,376 KB
testcase_04 AC 154 ms
4,564 KB
testcase_05 AC 153 ms
4,632 KB
testcase_06 AC 154 ms
4,648 KB
testcase_07 AC 175 ms
4,612 KB
testcase_08 AC 174 ms
4,696 KB
testcase_09 AC 174 ms
4,660 KB
testcase_10 AC 138 ms
4,596 KB
testcase_11 AC 147 ms
4,700 KB
testcase_12 AC 133 ms
4,380 KB
testcase_13 AC 159 ms
4,420 KB
testcase_14 AC 166 ms
4,628 KB
testcase_15 AC 148 ms
4,380 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

double Search(double l, double r, const ll k, vector<double> & d) {
	if (r - l < 0.00000001)
		return l;
	double p = (l + r) / 2.0;
	ll i, sum = 0;
	rep(i, d.size())
		sum += floor(d[i] / p);
	if (sum >= k)
		return Search(p, r, k, d);
	else
		return Search(l, p, k, d);
}

int main(void) {
	int num, i;
	ll k;
	double ans, ma = 0;
	cin >> num;
	vector<double> d(num);
	rep(i, num) {
		cin >> d[i];
		chmax(ma, d[i]);
	}
	cin >> k;
	ans = Search(0.0, ma, k, d);
	printf("%.15lf\n", ans);
	return 0;
}
0