結果
| 問題 |
No.478 一般門松列列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-25 03:32:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,133 bytes |
| コンパイル時間 | 4,547 ms |
| コンパイル使用メモリ | 194,280 KB |
| 最終ジャッジ日時 | 2025-01-21 18:05:06 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
int num = n - k - 2;
if (num == 0)
{
for (int i = 0; i < n; i++)
{
cout << 1 << ' ';
}
cout << '\n';
}
else
{
vector <int> res;
res.push_back(1);
res.push_back(3);
res.push_back(2);
num -= 1;
int idx = 3;
while (idx < n)
{
if (num == 0)
{
res.push_back(res[idx - 1]);
idx++;
}
else
{
if (idx % 2 == 1)
{
res.push_back(res[idx - 1] + 2);
idx++;
}
else
{
res.push_back(res[idx - 1] - 1);
idx++;
}
num--;
}
}
for (int i = 0; i < n; i++)
{
cout << res[i] << ' ';
}
cout << '\n';
}
return 0;
}