結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
horizon4096
|
| 提出日時 | 2017-12-28 09:45:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 5,000 ms |
| コード長 | 993 bytes |
| コンパイル時間 | 714 ms |
| コンパイル使用メモリ | 75,084 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-03-03 11:04:05 |
| 合計ジャッジ時間 | 3,637 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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 < 100; i++) {
double mid = (l + u) / 2;
if (C(mid)) l = mid;
else u = mid;
}
printf("%.14f\n", l);
return 0;
}
horizon4096