Submission #1175608


Source Code Expand

#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
typedef long long lli;
lli n,x;
vector<lli> w;
vector<unordered_map<lli,lli> > dp;
lli ans = 0;
int main(){
    cin >> n >> x;
    w = vector<lli> (n);
    for(lli i = 0;i < n;i++) cin >> w[i];
    dp = vector<unordered_map<lli,lli> > (n+2);
    dp[0][0] = 1;
    dp[n+1][0] = 1;
    for(lli i = 0;i < n/2;i++){
        for(auto itr = dp[i].begin();itr != dp[i].end();itr++){
            dp[i+1][itr->first] += dp[i][itr->first];
            dp[i+1][itr->first+w[i]] += dp[i][itr->first];
        }
    }
    for(lli i = n+1;i > n/2+1;i--){
        for(auto itr = dp[i].begin();itr != dp[i].end();itr++){
            dp[i-1][itr->first] += dp[i][itr->first];
            dp[i-1][itr->first+w[i-2]] += dp[i][itr->first];
        }
    }
    for(auto itr = dp[n/2].begin();itr != dp[n/2].end();itr++){
        ans += dp[n/2+1][x - itr->first] * itr->second;
    }
    cout << ans << endl;
    return 0;
} 

Submission Info

Submission Time
Task C - 無駄なものが嫌いな人
User deoxy
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1020 Byte
Status AC
Exec Time 93 ms
Memory 16292 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 1 ms 256 KB
max_2.txt AC 2 ms 512 KB
max_3.txt AC 1 ms 256 KB
max_4.txt AC 2 ms 384 KB
pair_1.txt AC 26 ms 5772 KB
pair_2.txt AC 3 ms 640 KB
power2_1.txt AC 17 ms 4224 KB
power2_2.txt AC 4 ms 1024 KB
power2_3.txt AC 2 ms 384 KB
power2_4.txt AC 2 ms 256 KB
power2_5.txt AC 5 ms 1536 KB
random_1.txt AC 48 ms 10276 KB
random_2.txt AC 53 ms 10276 KB
random_3.txt AC 93 ms 16292 KB
random_4.txt AC 84 ms 15908 KB
random_5.txt AC 3 ms 640 KB
random_6.txt AC 3 ms 640 KB
random_7.txt AC 4 ms 1024 KB
random_8.txt AC 26 ms 6272 KB
random_9.txt AC 50 ms 10276 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 2 ms 384 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