結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー horizon4096horizon4096
提出日時 2017-12-28 09:42:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 639 ms / 5,000 ms
コード長 994 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 71,144 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:24:09
合計ジャッジ時間 16,123 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 635 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 237 ms
6,944 KB
testcase_03 AC 457 ms
6,940 KB
testcase_04 AC 630 ms
6,944 KB
testcase_05 AC 621 ms
6,940 KB
testcase_06 AC 616 ms
6,940 KB
testcase_07 AC 639 ms
6,944 KB
testcase_08 AC 626 ms
6,940 KB
testcase_09 AC 628 ms
6,940 KB
testcase_10 AC 543 ms
6,944 KB
testcase_11 AC 581 ms
6,944 KB
testcase_12 AC 530 ms
6,940 KB
testcase_13 AC 560 ms
6,940 KB
testcase_14 AC 586 ms
6,940 KB
testcase_15 AC 528 ms
6,944 KB
testcase_16 AC 619 ms
6,944 KB
testcase_17 AC 606 ms
6,940 KB
testcase_18 AC 618 ms
6,940 KB
testcase_19 AC 625 ms
6,940 KB
testcase_20 AC 620 ms
6,940 KB
testcase_21 AC 615 ms
6,940 KB
testcase_22 AC 551 ms
6,940 KB
testcase_23 AC 579 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 13 ms
6,940 KB
testcase_26 AC 6 ms
6,944 KB
testcase_27 AC 5 ms
6,940 KB
testcase_28 AC 100 ms
6,940 KB
testcase_29 AC 50 ms
6,944 KB
testcase_30 AC 14 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |         scanf("%lld", &N);
      |         ~~~~~^~~~~~~~~~~~
main.cpp:45:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |                 scanf("%lf", &L[i]);
      |                 ~~~~~^~~~~~~~~~~~~~
main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |         scanf("%lld", &K);
      |         ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

ll N, K;
double L[200000];

bool C(double x)
{
	ll i = 0;
	for (int j = 0; j < N; j++) {
		i += (int)(L[j] / x);
	}
	return i >= K;
}

int main(int argc, char* argv[])
{
	scanf("%lld", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &L[i]);
	}
	scanf("%lld", &K);

	double l = 0, u = (double)linf;
	for (int i = 0; i < 2000; i++) {
		double mid = (l + u) / 2;
		if (C(mid)) l = mid;
		else u = mid;
	}
	printf("%.14f\n", l);

	return 0;
}
0