結果
| 問題 | No.115 遠足のおやつ |
| コンテスト | |
| ユーザー |
kapo
|
| 提出日時 | 2016-05-31 15:34:37 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 905 bytes |
| 記録 | |
| コンパイル時間 | 804 ms |
| コンパイル使用メモリ | 92,168 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-04-24 10:20:48 |
| 合計ジャッジ時間 | 2,721 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 40 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:44:23: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]', declared with attribute 'nodiscard' [-Wunused-result]
44 | unique(v.begin(), v.end());
| ~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
from main.cpp:4:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
875 | unique(_ForwardIterator __first, _ForwardIterator __last)
| ^~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
using namespace std;
int big(int n, int c)
{
int ret=0;
rep(i,0,c) ret += n-i;
return ret;
}
int small(int c)
{
int ret=0;
rep(i,1,c+1) ret += i;
return ret;
}
int main(void)
{
int N, D, K;
cin >> N >> D >> K;
int max = big(N,K);
int min = small(K);
printf("max=%d min=%d\n",max,min);
if(D > max || min > D) {
cout << -1 << endl;
return 0;
}
vector<int> v;
int mid = K;
rep(i,1,K) {
if(small(K-i) + big(N, i) + accumulate(v.begin(),v.end(),0) <= D) {
rep(j,0,i) v.pb(N-j);
mid = K-i;
}
unique(v.begin(), v.end());
}
rep(i,mid,N-mid) {
if(small(mid-1) + accumulate(v.begin(),v.end(),0) + i == D) v.pb(i);
}
rep(i,1,mid) v.pb(i);
sort(v.begin(),v.end());
for(auto i: v) cout << i << " ";
cout << endl;
return 0;
}
kapo