結果
| 問題 |
No.21 平均の差
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-07-29 00:12:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 973 bytes |
| コンパイル時間 | 1,134 ms |
| コンパイル使用メモリ | 73,348 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 21:24:40 |
| 合計ジャッジ時間 | 1,283 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
52 | scanf("%d%d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:55:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
55 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000003
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define SIZE 10000
int n,k,a[10];
double dfs(int h,int s=0,double minav=INF,double maxav=0){
double ret=0;
if(h!=k && s==n) return -1;
if(h==k){
if(s!=n) return -1;
return maxav-minav;
}
int sum=0;
double av;
for(int i=s;i<n;i++){
sum+=a[i];
av = sum/(double)(i-s+1);
ret =max(dfs(h+1,i+1,min(minav,av),max(maxav,av)),ret);
}
return ret;
}
int main(){
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
printf("%d\n",(int)ceil(dfs(0)));
return 0;
}
goodbaton