結果
| 問題 | No.2027 (1, 2, 3, …, N) 's Subset Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-19 01:45:44 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 448 bytes |
| 記録 | |
| コンパイル時間 | 899 ms |
| コンパイル使用メモリ | 93,948 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-06-29 01:20:19 |
| 合計ジャッジ時間 | 8,343 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
int n;
ll s;
cin >> n >> s;
vector<int> a;
for (int i = n; i > 0; i--)
{
if (i <= s)
{
a.push_back(i);
s -= i;
}
}
reverse(a.begin(), a.end());
cout << a.size() << endl;
for (int i : a)
{
cout << i << " ";
}
cout << endl;
}