結果
| 問題 | 
                            No.1238 選抜クラス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-10-07 10:29:43 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 37 ms / 2,000 ms | 
| コード長 | 590 bytes | 
| コンパイル時間 | 874 ms | 
| コンパイル使用メモリ | 78,816 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-20 03:18:08 | 
| 合計ジャッジ時間 | 2,073 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
ソースコード
#include<iostream>
#include<map>
using namespace std;
typedef pair<int,int> pii;
int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i], a[i] -= k;
    const int mod = 1000000007;
    map<int,int> dp;
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        map<int,int> ndp = dp;
        for(pii p : dp){
            (ndp[p.first+a[i]] += p.second) %= mod;
        }
        dp = ndp;
    }
    int ans = 0;
    for(pii p : dp){
        if(p.first >= 0)    (ans += p.second) %= mod;
    }
    cout << (ans+mod-1)%mod << endl;
    return 0;
}