結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-28 23:43:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 2,325 bytes |
| コンパイル時間 | 1,489 ms |
| コンパイル使用メモリ | 118,640 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 00:59:13 |
| 合計ジャッジ時間 | 2,439 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
// #ifdef DEBUG
// #define _GLIBCXX_DEBUG
// #endif
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif
template<typename A,typename B>
ostream &operator<<(ostream&os,const pair<A,B>& p){
os << "(" << p.first << "," << p.second << ")";
return os;
}
typedef complex<double> point;
template<typename T,std::size_t N>
struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
template<typename T>
struct _v_traits<T,1> {using type = std::vector<T>;};
template<typename T,std::size_t N=1>
using vec = typename _v_traits<T,N>::type;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
bool is_there_answer(int N,int D,int K){
int l = 0;
int r = 0;
for(int i=1;i<=K;i++) l+= i;
for(int i=N;i>=N-K+1;i--) r+= i;
dump(l);
dump(r);
return l <= D and D <= r;
}
vector<int> solve(int N,int D,int K){
if(not is_there_answer(N,D,K)){
return {-1};
}
vector<int> ans;
int sum = 0;
for(int i=1;i<=K;i++){
ans.push_back(i);
sum += i;
}
int last = 0;
while(sum < D){
if(ans[K-last-1] == N-last){
last++;
}
ans[K-last-1]++;
sum++;
}
return ans;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N,D,K;
cin >> N >> D >> K;
auto ans = solve(N,D,K);
for(int i : ans){
cout << i << " ";
}
cout << endl;
return 0;
}