結果
問題 | No.794 チーム戦 (2) |
ユーザー |
|
提出日時 | 2019-02-22 21:47:08 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 93 ms / 1,500 ms |
コード長 | 1,161 bytes |
コンパイル時間 | 1,576 ms |
コンパイル使用メモリ | 165,220 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 07:07:15 |
合計ジャッジ時間 | 4,024 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include "bits/stdc++.h"#pragma warning(disable:4996)using namespace std;long long int mod=1e9+7;pair<long long int, long long int>mul(pair<long long int, long long int>&l,pair<long long int, long long int>&r) {auto p=make_pair(l.first*r.first,l.second*r.first+r.second);return make_pair(p.first%mod,p.second%mod);}pair<long long int,long long int> solve(pair<long long int,long long int> a, long long int b) {pair<long long int,long long int>answer(1,0);if(b==0)return answer;if (b % 2) {answer=a;}auto x=solve(a,b/2);x=mul(x,x);answer=mul(answer,x);return answer;}int main() {int N,K;cin>>N>>K;vector<int>v(N);for(int i=0;i<N;++i)cin>>v[i];sort(v.begin(),v.end());long long int answer=1;int rest=-1;for (int i = N - 1; i >= 0; --i) {auto it=upper_bound(v.begin(),v.end(),K-v[i]);int num=it-v.begin();if (num >= i+1) {rest=N-2*(N-1-i);break;}num-=(N-1-i);if(num<0)num=0;answer*=num;answer%=static_cast<int>(1e9+7);}if (rest != -1) {rest--;while (rest > 0) {answer*=rest;rest-=2;answer%=static_cast<int>(1e9+7);}}cout<<answer<<endl;return 0;}