結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
keroberotte
|
| 提出日時 | 2014-11-17 01:59:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 30,464 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-03 10:11:09 |
| 合計ジャッジ時間 | 2,360 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | scanf("%d", &length[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:45:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | scanf("%lld", &k);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a, const void *b){
if(*(int *)a < *(int *)b){
return 1;
}
else if(*(int *)a == *(int *)b){
return 0;
}
return -1;
}
double binary_search(int n, int x[], long long k){
double l = 0, r = 1000000000;
for(int aiueo = 0;aiueo < 50;aiueo++){
long long current_num = 0;
double mid = (l + r) / 2.0;
for(int i = 0;i < n;i++){
current_num += (int)(x[i] / mid);
}
if(k <= current_num){
l = mid;
}
else{
r = mid;
}
}
return l;
}
int main(){
int n;
long long k;
scanf("%d", &n);
int length[n];
for(int i = 0;i < n;i++){
scanf("%d", &length[i]);
}
scanf("%lld", &k);
printf("%f\n", binary_search(n, length, k));
return 0;
}
keroberotte