結果

問題 No.794 チーム戦 (2)
ユーザー 37zigen37zigen
提出日時 2019-02-23 10:44:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 2,692 ms
コンパイル使用メモリ 147,068 KB
実行使用メモリ 5,400 KB
最終ジャッジ日時 2023-08-19 09:26:56
合計ジャッジ時間 4,627 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 84 ms
5,196 KB
testcase_17 AC 84 ms
5,088 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 WA -
testcase_28 WA -
testcase_29 AC 32 ms
5,096 KB
testcase_30 AC 32 ms
5,160 KB
testcase_31 AC 31 ms
5,100 KB
testcase_32 AC 31 ms
5,100 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

const long long mo=(long long)1e9+7;

long long A[2*100000];
bool vis[2*100000];

long long f(long long a){
  long long ret=1;
  while(a>0){
    ret=ret*(a-1)%mo;
    a-=2;
  }
  return ret;
}

int main(){

  int N;
  int K;

  std::cin>>N>>K;

  for(int i=0;i<N;++i){
    std::cin>>A[i];
    vis[i]=false;
  }
  std::sort(A,A+N);

  int t=0;
  long long ans=1;

  for(int i=N-1;i>=0;--i){
    while(t<N&&A[i]+A[t]<=K){
      vis[t]=true;
      ++t;
    }
    if(vis[i]){
      ans=ans*(std::max(1LL,f(i+1)));
      break;
    }
    ans=ans*(std::max(t-(N-1-i),0))%mo;
  }
  std::cout<<ans<<std::endl;
  return 0;
}
0