結果

問題 No.1619 Coccinellidae
ユーザー milanis48663220milanis48663220
提出日時 2021-07-22 22:35:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,625 bytes
コンパイル時間 1,278 ms
コンパイル使用メモリ 126,116 KB
実行使用メモリ 9,616 KB
最終ジャッジ日時 2023-09-24 17:56:26
合計ジャッジ時間 4,240 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 123 ms
7,808 KB
testcase_02 AC 157 ms
9,352 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 162 ms
9,384 KB
testcase_05 AC 96 ms
7,040 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 94 ms
6,692 KB
testcase_08 AC 91 ms
6,416 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 79 ms
6,176 KB
testcase_11 AC 112 ms
7,472 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 150 ms
9,068 KB
testcase_14 AC 163 ms
9,616 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> p(n);
    for(int i = 0; i < n-1; i++) p[i] = i;
    p[n-1] = m-accumulate(p.begin(), p.end(), 0ll);
    vector<ll> ans(n);
    set<int> st;
    for(int i = 0; i < n; i++) st.insert(i);
    ll rem = k;
    for(int i = 0; i < n; i++){
        if(rem >= (n-i-1)){
            // 残りの一番最後
            auto pt = st.end(); pt--;
            int idx = *pt;
            ans[idx] = p[i];
            rem -= (n-i-1);
            st.erase(idx);
        }else if(rem == 0){
            int idx = *st.begin();
            ans[idx] = p[i];
            st.erase(idx);
        }else{
            vector<int> v;
            for(int x: st) v.push_back(x);
            int idx = v[rem];
            ans[idx] = p[i];
            st.erase(idx);
            rem = 0;
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
}
0