結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
d2verb
|
| 提出日時 | 2015-10-04 16:06:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,842 bytes |
| コンパイル時間 | 873 ms |
| コンパイル使用メモリ | 96,412 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 01:07:31 |
| 合計ジャッジ時間 | 2,051 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;
//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)
#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int N, D, K;
vector<int> solve(int N, int D, int K){
vector<int> res;
if(K > N){
res.push_back(-1);
return res;
}
int mini = K * (K + 1) / 2;
int maxi = N * (N + 1) / 2 - (N - K) * (N - K + 1) / 2;
if(D < mini || maxi < D){
res.push_back(-1);
return res;
}
int last = 0;
for(int i = 1; i <= K; i++){
maxi = N * (N + 1) / 2 - (N - (K - i)) * (N - (K - i) + 1) / 2;
int now = max(D - maxi, last + 1);
res.push_back(now);
D -= now;
last = now;
}
return res;
}
int main(void){
ios_base::sync_with_stdio(0);
cin >> N >> D >> K;
vector<int> res = solve(N, D, K);
for(int i = 0; i < res.size(); i++){
if(i) cout << " ";
cout << res[i];
}
cout << endl;
return 0;
}
d2verb