結果
| 問題 | 
                            No.1238 選抜クラス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             mmn15277198
                         | 
                    
| 提出日時 | 2021-02-01 18:25:45 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 9 ms / 2,000 ms | 
| コード長 | 859 bytes | 
| コンパイル時間 | 613 ms | 
| コンパイル使用メモリ | 76,216 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-29 22:55:36 | 
| 合計ジャッジ時間 | 1,652 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
    int n , k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= k;
    }
    
    vector<ll> dp(22222 , 0);
    for(int i = 0; i < n; i++){
       int j = a[i] + 10000;
       vector<ll> dp2 = dp;
       for(int k = 0; k <= 20000; k++){
           dp[k] %= mod;
           if(k + a[i] > 0){
             dp2[k + a[i]] += dp[k];
             dp2[k + a[i]] %= mod;
           }
       }
       dp2[j] += 1;
       dp2[j] %= mod;
       dp = dp2;
    }
    
    ll ans = 0;
    for(int i = 10000; i <= 20000; i++){
        //cout << i << " : " << dp[i] << endl;
        ans += dp[i];
        ans %= mod;
    }
    cout << ans << endl;
    
    return 0;
}
            
            
            
        
            
mmn15277198