結果
問題 | No.794 チーム戦 (2) |
ユーザー |
![]() |
提出日時 | 2019-02-22 21:47:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 101 ms / 1,500 ms |
コード長 | 589 bytes |
コンパイル時間 | 642 ms |
コンパイル使用メモリ | 60,460 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 07:08:17 |
合計ジャッジ時間 | 3,047 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:24: warning: ‘rem’ may be used uninitialized in this function [-Wmaybe-uninitialized] 32 | for(int i = rem-1; i > 0; i-=2) ans *= i, ans %= mod; | ~~~^~
ソースコード
#include <iostream> #include <algorithm> #define llint long long #define mod 1000000007 using namespace std; llint n, k; llint a[200005]; int main(void) { cin >> n >> k; for(int i = 1; i <= n; i++) cin >> a[i]; sort(a+1, a+n+1); llint ans = 1, rem; for(int i = n; i >= 1; i--){ if(a[i] <= k/2){ rem = n - 2*(n-i); break; } int cnt = upper_bound(a+1, a+n+1, k-a[i]) - (a+1); cnt -= (n-i); if(cnt <= 0){ cout << 0 << endl; return 0; } ans *= cnt, ans %= mod; } for(int i = rem-1; i > 0; i-=2) ans *= i, ans %= mod; cout << ans << endl; return 0; }