結果

問題 No.1619 Coccinellidae
ユーザー nawawannawawan
提出日時 2021-07-22 22:01:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 167,360 KB
実行使用メモリ 5,676 KB
最終ジャッジ日時 2023-09-24 16:56:50
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long M, K;
    cin >> N >> M >> K;
    vector<long long> A(N);
    for(int i = 0; i < N; i++){
        if(i != N - 1) A[i] = i;
        else A[i] = M - (long long)(N - 2) * (long long)(N - 1) / 2;
    }
    vector<long long> temp(N);
    int now = 0;
    vector<long long> B(N, -1);
    long long ind = N - 1;
    while(K > 0){
        if(K >= ind){
            K -= ind;
            B[ind] = A[now];
            now++;
            ind--;
        }
        else{
            B[K] = A[now];
            K = 0;
            now++;
        }
    }
    for(int i = 0; i < N; i++){
        if(B[i] == -1){
            B[i] = A[now];
            now++;
        }
    }
    for(int i = 0; i < N; i++) printf("%lld\n", B[i]);
}
0