結果

問題 No.1619 Coccinellidae
ユーザー tabae326tabae326
提出日時 2021-07-22 22:18:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 201,596 KB
実行使用メモリ 5,056 KB
最終ジャッジ日時 2023-09-24 17:25:39
合計ジャッジ時間 3,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 9 ms
4,780 KB
testcase_02 AC 11 ms
4,924 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 11 ms
5,056 KB
testcase_05 AC 7 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 8 ms
4,644 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 10 ms
4,752 KB
testcase_14 AC 11 ms
4,936 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    iota(a.begin(), a.end(), 0);
    a[n-1] += m - n * (n - 1) / 2;
    ll p = 0, sum = 0;
    vector<ll> ans;
    for(ll i = n-1; i >= 1; i--) {
        if(sum + i <= k) {
            sum += i;
            ans.push_back(a[i]);
        } else {
            p = i;
            break;
        }
    }
    for(ll i = p; i >= 1; i--) {
        if(sum == k) break;
        sum++;
        swap(a[i], a[i-1]);
    }
    rep(i, 0, p+1) ans.push_back(a[i]);
    rep(i, 0, n) cout << ans[i] << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
0