結果

問題 No.1635 Let’s Sort Integers!!
ユーザー ytftytft
提出日時 2021-08-26 16:21:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 905 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 170,548 KB
実行使用メモリ 16,972 KB
最終ジャッジ日時 2024-04-29 08:11:12
合計ジャッジ時間 16,006 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
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 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 90 ms
11,404 KB
testcase_61 AC 89 ms
12,220 KB
testcase_62 AC 97 ms
16,972 KB
testcase_63 AC 88 ms
11,888 KB
testcase_64 AC 89 ms
12,824 KB
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 AC 2 ms
5,376 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 88 ms
11,532 KB
testcase_71 AC 91 ms
12,456 KB
testcase_72 AC 88 ms
12,012 KB
testcase_73 AC 88 ms
11,560 KB
testcase_74 AC 95 ms
15,564 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int min(int a,long long b){
    if(a>b){
        return (int)b;
    }else{
        return a;
    }
}

int main(){
    long long N,K;
    cin>>N>>K;
    if(N-1>K||N*(N-1)/2<K){
        cout<<-1<<endl;
        return 0;
    }
    int pointer=N-1;
    vector<int> memo(0);
    for(int i=N-1;i>=1;--i){
        memo.push_back(pointer);
        if(K==0)break;
        if(N/2<=pointer){
            pointer-=min(i,K);
            K-=min(i,K);
        }else{
            pointer+=min(i,K);
            K-=min(i,K);
        }
    }
    vector<int> used(N),ans(0);
    for(int i=0;i<memo.size();i++){
        used[memo[i]]=1;
    }
    for(int i=memo.size()-1;i>=1;--i){
        ans.push_back(memo[i]);
    }
    for(int i=0;i<N;++i){
        if(!used[i])ans.push_back(i);
    }
    ans.push_back(N-1);
    for(int i=0;i<N;++i){
        cout<<(ans[i]+1)<<' ';
    }
}
0