結果

問題 No.1619 Coccinellidae
ユーザー ぷらぷら
提出日時 2021-07-22 21:49:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,039 bytes
コンパイル時間 2,202 ms
コンパイル使用メモリ 205,080 KB
実行使用メモリ 5,144 KB
最終ジャッジ日時 2023-09-24 16:29:13
合計ジャッジ時間 5,477 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 102 ms
4,864 KB
testcase_02 AC 131 ms
4,944 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 131 ms
5,144 KB
testcase_05 AC 76 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 81 ms
4,412 KB
testcase_08 AC 74 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 68 ms
4,376 KB
testcase_11 AC 94 ms
4,848 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 122 ms
5,080 KB
testcase_14 AC 134 ms
4,780 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    long long N,M,K;
    cin >> N >> M >> K;
    vector<long long>tmp;
    for(int i = 0; i <= N-2; i++) {
        tmp.push_back(i);
        M -= i;
    }
    tmp.push_back(M);
    vector<int>ans;
    vector<int>tmp2;
    for(int i = N-1; i >= 0; i--) {
        if(K >= i) {
            K -= i;
            ans.push_back(N-i);
        }
        else {
            reverse(ans.begin(),ans.end());
            for(int j = N-i+1; j <= N; j++) {
                if(j-N+i-1 == K) {
                    tmp2.push_back(N-i);
                }
                tmp2.push_back(j);
            }
            for(int j = 0; j < ans.size(); j++) {
                tmp2.push_back(ans[j]);
            }
            break;
        }
    }
    if(tmp2.size() == 0) {
        reverse(ans.begin(),ans.end());
        for(int j = 0; j < ans.size(); j++) {
            tmp2.push_back(ans[j]);
        }
    }
    for(int i = 0; i < tmp.size(); i++) {
        cout << tmp[tmp2[i]-1] << endl;
    }
}
0