結果

問題 No.1238 選抜クラス
ユーザー ysystem7ysystem7
提出日時 2020-09-25 22:52:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 2,077 bytes
コンパイル時間 2,719 ms
コンパイル使用メモリ 215,832 KB
実行使用メモリ 11,820 KB
最終ジャッジ日時 2023-09-10 16:03:43
合計ジャッジ時間 4,335 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 3 ms
4,748 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,608 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,568 KB
testcase_16 AC 3 ms
4,752 KB
testcase_17 AC 9 ms
11,548 KB
testcase_18 AC 9 ms
11,676 KB
testcase_19 AC 9 ms
11,576 KB
testcase_20 AC 8 ms
11,640 KB
testcase_21 AC 8 ms
11,748 KB
testcase_22 AC 9 ms
11,608 KB
testcase_23 AC 9 ms
11,548 KB
testcase_24 AC 9 ms
11,536 KB
testcase_25 AC 9 ms
11,608 KB
testcase_26 AC 9 ms
11,608 KB
testcase_27 AC 9 ms
11,588 KB
testcase_28 AC 9 ms
11,708 KB
testcase_29 AC 9 ms
11,540 KB
testcase_30 AC 5 ms
7,492 KB
testcase_31 AC 7 ms
9,700 KB
testcase_32 AC 8 ms
9,496 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 8 ms
11,752 KB
testcase_35 AC 5 ms
7,492 KB
testcase_36 AC 3 ms
5,128 KB
testcase_37 AC 5 ms
7,540 KB
testcase_38 AC 9 ms
11,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

ll dp[105][10005];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,kk;
    cin>>n>>kk;
    V<int> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]-=kk;
    }
    sort(all(a));
    int pos=lb(all(a),0)-a.begin();
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        V<ll> tmp(10001,0);
        if(a[i]>=0){
            for(int j=-10000;j<=0;j++){
                tmp[-j]+=dp[i][-j];
                tmp[-j]%=mod;
                ll tmp2=min(0,j+a[i]);
                tmp[-tmp2]+=dp[i][-j];
                tmp[-tmp2]%=mod;
            }
        }else{
            for(int j=0;j>=-10000;j--){
                tmp[-j]+=dp[i][-j];
                tmp[-j]%=mod;
                ll tmp2=max(-10000,j+a[i]);
                tmp[-tmp2]+=dp[i][-j];
                tmp[-tmp2]%=mod;
            }
        }
        for(int j=0;j<=10000;j++) dp[i+1][j]=tmp[j];
    }
    dp[n][0]--;
    if(dp[n][0]<0) dp[n][0]+=mod;
    out(dp[n][0]);
}
0