結果

問題 No.115 遠足のおやつ
ユーザー Lay_ecLay_ec
提出日時 2014-12-28 23:58:55
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 757 bytes
コンパイル時間 2,638 ms
コンパイル使用メモリ 72,900 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 18:53:11
合計ジャッジ時間 3,250 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,384 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,384 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <cstring>

using namespace std;

int main()
{	
	int n,d,k;
	cin>>n>>d>>k;
	
	vector<int> res(k);
	int num=0;
	for(int i=0;i<k;i++){
		res[i]=i+1;
		num+=i+1;
	}

	if(num>d){cout<<-1<<endl;}
	else{
		int rest=d-num;
		if(res[k-1]+rest<=n){res[k-1]+=rest; rest=0;}
		else {res[k-1]=n; rest-=n-k;}
		for(int i=k-2;i>=0 && rest!=0;i--){
			if(res[i]+rest<=res[i+1]){ res[i]+=rest; rest=0;}
			else{rest-=res[i+1]-res[i]-1; res[i]=res[i+1]-1;  }
		}
		if(rest!=0) cout<<-1<<endl;
		else{
			for(int i=0;i<k;i++) cout<<res[i]<<" ";
			cout<<endl;
		}
	}

	return 0;

}
0