結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー nebukuro09nebukuro09
提出日時 2016-09-23 14:45:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 23,808 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-04-28 22:14:57
合計ジャッジ時間 8,114 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 43 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 43 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%d", &L[i]);
      |     ~~~~~^~~~~~~~~~~~~
main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%d", &K);
      |   ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main() {
  int N, K;
  int L[200000];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &L[i]);
  }
  scanf("%d", &K);

  double EPS = 0.0000000001;
  double high = 1000000000;
  double low = 0.0;
  double middle;
  int sum;

  while (high-low > EPS) {
    middle = (high+low)/2.0;
    sum = 0;
    for (int i = 0; i < N; i++)
      sum += (int)(L[i]/middle);
    if (sum >= K)
      low = middle;
    else
      high = middle;
  }

  printf("%.09f", high);
  return 0;
}
0