結果

問題 No.5001 排他的論理和でランニング
ユーザー tecchaxntecchaxn
提出日時 2018-03-16 22:59:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 59 ms / 1,500 ms
コード長 824 bytes
コンパイル時間 1,097 ms
実行使用メモリ 7,424 KB
スコア 35,933,375
最終ジャッジ日時 2020-03-12 19:29:27
ジャッジサーバーID
(参考情報)
judge9 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
5,376 KB
testcase_01 AC 10 ms
5,380 KB
testcase_02 AC 15 ms
5,376 KB
testcase_03 AC 30 ms
5,380 KB
testcase_04 AC 59 ms
5,380 KB
testcase_05 AC 21 ms
5,376 KB
testcase_06 AC 37 ms
5,380 KB
testcase_07 AC 41 ms
5,380 KB
testcase_08 AC 51 ms
5,380 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 24 ms
5,376 KB
testcase_12 AC 19 ms
5,376 KB
testcase_13 AC 52 ms
5,380 KB
testcase_14 AC 34 ms
5,376 KB
testcase_15 AC 21 ms
5,380 KB
testcase_16 AC 11 ms
5,380 KB
testcase_17 AC 15 ms
5,380 KB
testcase_18 AC 32 ms
5,380 KB
testcase_19 AC 24 ms
5,380 KB
testcase_20 AC 17 ms
5,376 KB
testcase_21 AC 16 ms
5,380 KB
testcase_22 AC 7 ms
7,424 KB
testcase_23 AC 6 ms
5,380 KB
testcase_24 AC 23 ms
5,376 KB
testcase_25 AC 48 ms
5,376 KB
testcase_26 AC 40 ms
5,380 KB
testcase_27 AC 27 ms
5,380 KB
testcase_28 AC 41 ms
5,376 KB
testcase_29 AC 47 ms
5,376 KB
testcase_30 AC 8 ms
5,380 KB
testcase_31 AC 36 ms
5,380 KB
testcase_32 AC 17 ms
5,380 KB
testcase_33 AC 57 ms
5,416 KB
testcase_34 AC 59 ms
5,376 KB
testcase_35 AC 38 ms
5,376 KB
testcase_36 AC 54 ms
5,380 KB
testcase_37 AC 41 ms
5,380 KB
testcase_38 AC 16 ms
5,380 KB
testcase_39 AC 22 ms
5,376 KB
testcase_40 AC 28 ms
5,380 KB
testcase_41 AC 8 ms
5,380 KB
testcase_42 AC 26 ms
5,376 KB
testcase_43 AC 28 ms
5,380 KB
testcase_44 AC 49 ms
6,148 KB
testcase_45 AC 52 ms
5,376 KB
testcase_46 AC 51 ms
5,380 KB
testcase_47 AC 24 ms
5,376 KB
testcase_48 AC 17 ms
5,380 KB
testcase_49 AC 45 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;

//-----------------------------------------------------------------------

signed main()
{   
    int N,M; cin>>N>>M;
    vector<int> a(N);
    vector<int> v[30];
    REP(i,N){
        cin>>a[i];
        int x=a[i],cnt=0;
        while(x>0){
            cnt++;
            x>>=1;
        }
        v[cnt].push_back(a[i]);
    }
    
    vector<int> ans;
    for(int i=29;i>=0;i--){
        if(v[i].size()>0){
            ans.push_back(v[i][0]);
            break;
        }
    }

    sort(ALL(a));
    REP(i,N){
        if(a[i]!=ans[0] and ans.size()<M) ans.push_back(a[i]);
    }
    
    REP(i,M){
        if(i) cout<<' ';
        cout<<ans[i];
    }
    cout<<endl;
    
 
}
0