結果

問題 No.1457 ツブ消ししとるなHard
ユーザー Izayoi_R_sakuraIzayoi_R_sakura
提出日時 2021-03-31 21:39:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 2,369 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 143,504 KB
実行使用メモリ 55,128 KB
最終ジャッジ日時 2023-08-22 00:04:20
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 49 ms
55,128 KB
testcase_05 AC 44 ms
48,936 KB
testcase_06 AC 50 ms
55,112 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 17 ms
20,080 KB
testcase_13 AC 5 ms
6,560 KB
testcase_14 AC 4 ms
6,428 KB
testcase_15 AC 5 ms
6,760 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 50 ms
55,128 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
template<class T> using V = vector<T> ;
template<class T> using VV = V<V<T>> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
long double pie = acos(-1) ;
ll INF = 1e18 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll extGCD(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x = 1 ;
        y = 0 ;
        return a ;
    }
    ll d = extGCD(b,a%b,y,x) ;
    y -= a/b*x ;
    return d ;
}
void fix_cout(){cout << fixed << setprecision(20) ;}
template<class T> void chmax(T &a,T &b){if(a<b) a = b ;}
template<class T> void chmin(T &a,T &b){if(a>b) a = b ;}

int main(){
    int n,m,x,y,z ;
    cin >> n >> m >> x >> y >> z ;
    V<int> a(n) ;
    for(auto &i:a) cin >> i ;
    sort(all(a)) ;
    if(m!=n&&a[n-m-1]>=x) cout << "Handicapped" << endl ;
    else{
        ll sum = 0 ;
        int cnt = 0 ;
        V<int> b ;
        for(int i=0;i<n;i++){
            if(a[i]<=y) continue ;
            else if(a[i]>=x){
                sum += a[i] ;
                cnt++ ;
            }else b.push_back(a[i]) ;
        }
        n = b.size() ;
        VV<V<ll>> dp(n+1,VV<ll>(n+1,V<ll>(50*n+1,0))) ;
        dp[0][0][0] = 1 ;
        for(int i=1;i<=n;i++){
            dp[i] = dp[i-1] ;
            for(int j=0;j<=i-1;j++) for(int k=0;k<=50*n;k++){
                dp[i][j+1][k+b[i-1]] += dp[i-1][j][k] ;
            }
        }
        ll ans = 0 ;
        for(int i=0;i<=n;i++){
            if(i+cnt>m) break ;
            if(i+cnt==0) continue ;
            ll tmp = z*(cnt+i)-sum ;
            if(tmp<0||tmp>50*n) continue ;
            ans += dp[n][i][z*(cnt+i)-sum] ;
        }
        cout << ans << endl ;
        // for(auto i:dp[n]){
        //     for(int j=0;j<30;j++) cout << i[j] << " " ; cout << endl ;
        // }
    }
}
0