結果

問題 No.1635 Let’s Sort Integers!!
ユーザー chocoruskchocorusk
提出日時 2021-08-18 04:41:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,746 bytes
コンパイル時間 3,204 ms
コンパイル使用メモリ 188,936 KB
実行使用メモリ 11,672 KB
最終ジャッジ日時 2024-04-19 12:21:46
合計ジャッジ時間 15,908 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,944 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 1 ms
6,940 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 1 ms
6,944 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 1 ms
6,944 KB
testcase_48 AC 1 ms
6,940 KB
testcase_49 AC 2 ms
6,940 KB
testcase_50 AC 1 ms
6,940 KB
testcase_51 AC 1 ms
6,944 KB
testcase_52 AC 2 ms
6,940 KB
testcase_53 AC 2 ms
6,940 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 2 ms
6,940 KB
testcase_60 AC 91 ms
6,944 KB
testcase_61 AC 102 ms
11,564 KB
testcase_62 AC 104 ms
11,520 KB
testcase_63 AC 99 ms
11,492 KB
testcase_64 AC 100 ms
11,556 KB
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 AC 2 ms
6,940 KB
testcase_69 AC 3 ms
6,944 KB
testcase_70 AC 89 ms
6,940 KB
testcase_71 AC 99 ms
11,484 KB
testcase_72 AC 99 ms
11,672 KB
testcase_73 AC 101 ms
11,640 KB
testcase_74 AC 100 ms
11,620 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 2 ms
6,940 KB
testcase_79 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll n, k;
    cin>>n>>k;
    ll s=0;
    for(ll i=1; i<n; i++){
        s+=i;
    }
    if(k<n-1 || k>s){
        cout<<-1<<endl;
        return 0;
    }
    if(k==n-1){
        for(ll i=1; i<=n; i++){
            cout<<i;
            if(i<n) cout<<" ";
        }
        cout<<endl;
        return 0;
    }
    for(ll i=1; i<n-1; i++){
        if(s-i<=k){
            deque<int> ans;
            int v=1;
            for(int j=0; j<k-(s-i)+1; j++){
                ans.push_front(v);
                v++;
            }
            for(int j=0; j<i+1-(k-(s-i)); j++){
                ans.push_back(v);
                v++;
            }
            int j=0;
            while(v<=n){
                if(j&1) ans.push_back(v);
                else ans.push_front(v);
                v++; j++;
            }
            int ans1[1000010];
            for(int j=1; j<=n; j++){
                ans1[ans[j-1]]=j;
            }
            for(int j=1; j<=n; j++){
                cout<<ans1[j];
                if(j<n) cout<<" ";
            }
            cout<<endl;
            return 0;
        }
        s-=i;
    }
    return 0;
}
0