結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー Keitaro NaruseKeitaro Naruse
提出日時 2023-12-02 15:31:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 73,912 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:31:54
合計ジャッジ時間 2,874 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 18 ms
6,676 KB
testcase_02 AC 21 ms
6,676 KB
testcase_03 AC 19 ms
6,676 KB
testcase_04 AC 22 ms
6,676 KB
testcase_05 AC 22 ms
6,676 KB
testcase_06 AC 140 ms
6,676 KB
testcase_07 AC 145 ms
6,676 KB
testcase_08 AC 140 ms
6,676 KB
testcase_09 AC 140 ms
6,676 KB
testcase_10 AC 139 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 * @file 2560.cpp
 * @brief yukicoder No.2560 A_1 < A_2 < ... < A_N
 * @author Keitaro Naruse
 * @date 2023-12-02
 * @copyright MIT License
 * @details https://yukicoder.me/problems/no/2560
 * */

// # Solution

#include <iostream>
#include <vector>

template < class T >
std::ostream& operator<<( std::ostream& os, const std::vector< T >& v ) {
    for( auto it = v.begin( ); it != v.end( ); it++ ) {
        os << *it << ( it == --v.end( ) ? "" : " " );
    }
    return os;
}

int main( ) {
    //  Read T = [ 1, 10^5 ]
    int T;
    std::cin >> T;
    //  Multiple queries
    for( int t = 0; t < T; t++ ) {
        //  Read N = [ 1, 2*10^5 ], X = [ 1, 10^18 ]
        long long N;
        long long X;
        std::cin >> N >> X;

        //  Main::Preprocess
        std::vector< long long > A( N );
        for( int i = 0; i < N; i++ ) {
            A.at( i ) = ( long long ) ( i + 1 );
        }
        //  Main::Find a solution
        A.at( N - 1 ) += X - N * ( N + 1LL ) / 2LL;
        //  Main::Output a solution
        if( A.at( N - 1 ) >= N ) {
            std::cout << A << std::endl;
        } else {
            std::cout << -1 << std::endl;
        }
    }
    
    //  Finalize
    return 0;
}
0