結果

問題 No.21 平均の差
ユーザー evawenisevawenis
提出日時 2020-06-07 11:11:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 205,064 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 04:18:18
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,k; cin>>n>>k;
	vector<int>val(n); for(auto&&i:val)cin>>i;
	sort(val.rbegin(),val.rend());
	int ans=0;
	for(int i=0,mx=0;i<n;++i){
		mx+=val.at(i);
		int mn=0;
		for(int j=n-1;j>=0&&j-i>k-2;--j){
			mn+=val.at(j);cout<<mx<<" "s<<mn<<"\n"s;
			ans=max(ans,(int)ceil((double)mx/(i+1)-(double)mn/(n-j)));
		}
	}
	cout<<ans<<"\n"s;
}
0