Submission #1832865


Source Code Expand

#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int main(){
    vector<int>V1,V2;
    int n,x;
    cin>>n>>x;
    int w[32];
    REP(i,n)cin>>w[i];
    REP(i,1<<(n/2)){
        int res=0;
        REP(j,n/2)if(1&(i>>j))res+=w[j];
        V1.PB(res);
    }
    REP(i,1<<((n+1)/2)){
        int res=0;
        REP(j,(n+1)/2)if(1&(i>>j))res+=w[n/2+j];
        V2.PB(res);
    }
    sort(ALL(V2));
    int ans=0;
    REP(i,V1.size()){
        ans+=(upper_bound(ALL(V2),x-V1[i])-lower_bound(ALL(V2),x-V1[i]));
    }
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task C - 無駄なものが嫌いな人
User nishidata
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1097 Byte
Status AC
Exec Time 23 ms
Memory 892 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 28
Set Name Test Cases
All max_1.txt, max_2.txt, max_3.txt, max_4.txt, pair_1.txt, pair_2.txt, power2_1.txt, power2_2.txt, power2_3.txt, power2_4.txt, power2_5.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt
Case Name Status Exec Time Memory
max_1.txt AC 13 ms 892 KB
max_2.txt AC 16 ms 892 KB
max_3.txt AC 13 ms 892 KB
max_4.txt AC 15 ms 892 KB
pair_1.txt AC 23 ms 892 KB
pair_2.txt AC 20 ms 892 KB
power2_1.txt AC 15 ms 892 KB
power2_2.txt AC 15 ms 892 KB
power2_3.txt AC 15 ms 892 KB
power2_4.txt AC 14 ms 892 KB
power2_5.txt AC 2 ms 384 KB
random_1.txt AC 15 ms 768 KB
random_2.txt AC 15 ms 768 KB
random_3.txt AC 14 ms 892 KB
random_4.txt AC 23 ms 892 KB
random_5.txt AC 17 ms 892 KB
random_6.txt AC 13 ms 768 KB
random_7.txt AC 21 ms 892 KB
random_8.txt AC 19 ms 892 KB
random_9.txt AC 12 ms 768 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB
sample_4.txt AC 1 ms 256 KB
small_1.txt AC 1 ms 256 KB
small_2.txt AC 1 ms 256 KB
small_3.txt AC 1 ms 256 KB
small_4.txt AC 1 ms 256 KB