Submission #1357589
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define int long long int w[50]; int pw[1<<17]; signed main(){ int n,x; cin>>n>>x; for(int i=1;i<=n;i++)cin>>w[i]; n+=2; int n2=n/2; for(int i=0;i<1<<n2;i++){ int sw=0; for(int j=0;j<n2;j++){ if(i>>j&1){ sw+=w[j]; } } pw[i]=sw; } sort(pw,pw+(1<<n2)); int res=0; for(int i=0;i<1<<(n-n2);i++){ int sw=0; for(int j=0;j<n-n2;j++){ if(i>>j&1){ sw+=w[n2+j]; } } if(sw<=x){ auto itr=equal_range(pw,pw+n,x-sw); res+=*itr.second-*itr.first; } } cout<<res<<endl; }
Submission Info
Submission Time | |
---|---|
Task | C - 無駄なものが嫌いな人 |
User | Rho17 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 616 Byte |
Status | WA |
Exec Time | 23 ms |
Memory | 1280 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
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 | WA | 18 ms | 1280 KB |
max_2.txt | WA | 20 ms | 1280 KB |
max_3.txt | WA | 18 ms | 1280 KB |
max_4.txt | WA | 18 ms | 1280 KB |
pair_1.txt | WA | 22 ms | 1280 KB |
pair_2.txt | WA | 20 ms | 1280 KB |
power2_1.txt | WA | 22 ms | 1280 KB |
power2_2.txt | WA | 20 ms | 1280 KB |
power2_3.txt | WA | 19 ms | 1280 KB |
power2_4.txt | WA | 19 ms | 1280 KB |
power2_5.txt | WA | 2 ms | 256 KB |
random_1.txt | WA | 16 ms | 768 KB |
random_2.txt | WA | 15 ms | 768 KB |
random_3.txt | AC | 22 ms | 1280 KB |
random_4.txt | WA | 23 ms | 1280 KB |
random_5.txt | WA | 19 ms | 1280 KB |
random_6.txt | WA | 14 ms | 768 KB |
random_7.txt | WA | 21 ms | 1280 KB |
random_8.txt | WA | 22 ms | 1280 KB |
random_9.txt | WA | 15 ms | 768 KB |
sample_1.txt | AC | 1 ms | 256 KB |
sample_2.txt | AC | 1 ms | 256 KB |
sample_3.txt | WA | 1 ms | 256 KB |
sample_4.txt | WA | 1 ms | 256 KB |
small_1.txt | WA | 1 ms | 256 KB |
small_2.txt | AC | 1 ms | 256 KB |
small_3.txt | WA | 1 ms | 256 KB |
small_4.txt | AC | 1 ms | 256 KB |