結果
| 問題 |
No.2027 (1, 2, 3, …, N) 's Subset Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-19 02:02:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 632 bytes |
| コンパイル時間 | 4,542 ms |
| コンパイル使用メモリ | 250,624 KB |
| 最終ジャッジ日時 | 2025-01-30 11:01:42 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
using ll = long long;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void)
{
int n, s;
cin >> n >> s;
int summ = 0;
vector<int> ans;
for(int i = n; i > 0; i--){
if(summ + i <= s){
ans.push_back(i);
summ += i;
}
}
reverse(all(ans));
cout << ans.size() << endl;
for(int i = 0; i < ans.size() - 1; i++){
cout << ans[i] << ' ';
}
cout << ans.back() << endl;
return 0;
}