結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2017-07-11 23:29:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 548 bytes |
| コンパイル時間 | 1,388 ms |
| コンパイル使用メモリ | 160,352 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 01:24:33 |
| 合計ジャッジ時間 | 2,877 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
using namespace std;
bool check(int L, int N, int D, int K){
if (N - L + 1 < K) return false;
int l = 0,h = 0;
REP(i,0,K){
l += L + i;
h += N - i;
}
return l <= D && h >= D;
}
int main(){
int N, D, K;
cin >> N >> D >> K;
if (check(1, N, D, K)){
for (int i = 1; i <= N && K > 0; i++){
if (check(i + 1, N, D - i, K - 1)){
if (K == 1){
cout << i << endl;
}
else cout << i << " ";
D -= i;
K--;
}
}
}
else cout << "-1" << endl;
}
dnish