結果

問題 No.1238 選抜クラス
ユーザー karinohitokarinohito
提出日時 2021-05-08 18:57:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 2,276 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 106,392 KB
実行使用メモリ 27,324 KB
最終ジャッジ日時 2023-10-17 02:10:05
合計ジャッジ時間 3,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 4 ms
5,940 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 4 ms
5,148 KB
testcase_08 AC 4 ms
5,940 KB
testcase_09 AC 5 ms
6,996 KB
testcase_10 AC 4 ms
5,412 KB
testcase_11 AC 5 ms
6,744 KB
testcase_12 AC 4 ms
6,204 KB
testcase_13 AC 5 ms
6,204 KB
testcase_14 AC 4 ms
5,940 KB
testcase_15 AC 5 ms
6,996 KB
testcase_16 AC 5 ms
6,744 KB
testcase_17 AC 24 ms
27,324 KB
testcase_18 AC 23 ms
26,796 KB
testcase_19 AC 24 ms
26,804 KB
testcase_20 AC 23 ms
26,268 KB
testcase_21 AC 23 ms
25,476 KB
testcase_22 AC 23 ms
27,324 KB
testcase_23 AC 23 ms
27,324 KB
testcase_24 AC 24 ms
27,324 KB
testcase_25 AC 23 ms
27,324 KB
testcase_26 AC 24 ms
27,324 KB
testcase_27 AC 24 ms
27,324 KB
testcase_28 AC 24 ms
27,324 KB
testcase_29 AC 24 ms
26,804 KB
testcase_30 AC 9 ms
10,956 KB
testcase_31 AC 14 ms
16,764 KB
testcase_32 AC 20 ms
22,044 KB
testcase_33 AC 3 ms
5,148 KB
testcase_34 AC 20 ms
23,892 KB
testcase_35 AC 10 ms
12,804 KB
testcase_36 AC 6 ms
8,052 KB
testcase_37 AC 9 ms
11,228 KB
testcase_38 AC 23 ms
26,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<pair<ll, ll>>>;


class quo{
    public:
    ll de;
    ll nu;


    ll gcd(ll a,ll b){
        ll c = a;
	    while (a % b != 0) {
            c = a % b;
            a = b;
            b = c;
        }
	    return b;
    }
    quo re(){
        
        quo res;
        ll g=gcd(this->de,this->nu);
        res.de=this->de/g;
        res.nu=this->nu/g;
        return res;

    }
    quo operator +(const quo &a){
        quo c;
        c.nu=this->nu*a.nu;
        c.de=this->nu*a.de+this->de*a.nu;
        return c.re();
    }
    quo operator -(const quo &a){
        quo c;
        c.nu=this->nu*a.nu;
        c.de=-this->nu*a.de+this->de*a.nu;
        return c.re();
    }
    quo operator *(const quo &a){
        quo c;
        c.nu=this->nu*a.nu;
        c.de=this->de*a.de;
        return c.re();
    }
    
};



int main(){
    ll mod=1e9+7;
  ll N,K;
  cin>>N>>K;
  vll A(N);
  rep(i,N){
      cin>>A[i];
      A[i]-=K;
  }
  vector<vll> DP(N+1,vll(30000,0));
  DP[0][15000]=1;
  rep(i,N){
      rep(j,30000){
          if(DP[i][j]!=0){
              DP[i+1][j]+=DP[i][j];
              DP[i+1][j]%=mod;
              DP[i+1][j+A[i]]+=DP[i][j];
              DP[i+1][j+A[i]]%=mod;
          }
      }
  }
  ll an=mod-1;
  for(ll i=15000;i<30000;i++){
      an+=DP[N][i];
  }
cout<<an%mod<<endl;
}
0