結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
![]() |
提出日時 | 2015-10-01 00:15:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,019 bytes |
コンパイル時間 | 1,577 ms |
コンパイル使用メモリ | 162,420 KB |
実行使用メモリ | 13,344 KB |
最終ジャッジ日時 | 2025-03-03 10:24:55 |
合計ジャッジ時間 | 8,570 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 1 TLE * 1 -- * 27 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) #define int long long #define ALL(a) (a).begin(),(a).end() #define SUM(a) accumulate(ALL(a), 0) #define FOR(i, a, b) for(int i=(a);i<(b);i++) int N, K; vector<int> L(222222); signed main() { cin >> N; REP(i,N) cin >> L[i]; cin >> K; sort(ALL(L)); reverse(ALL(L)); double maxl = 1.0 * SUM(L) / K; if (K <= N) { cout << L[K-1] << endl; return 0; } int cut = (int)(L[0] / maxl); while(true) { double maxlen = min(1.0 * L[0] / cut, (double)L[N-1]); int cnt = N + cut - 1; bool ok = false; FOR(i,1,N) { if (cnt >= K) { ok = true; break; } int cuti = (int)(L[i] / maxlen); maxlen = min(maxlen, 1.0 * L[i] / cuti); cnt += cut - 1; } if (ok) { printf("%.14f\n", maxlen); return 0; } cut++; } }