Submission #43504

# Submission time Handle Problem Language Result Execution time Memory
43504 2018-03-16T19:15:07 Z Hassoony Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
623 ms 33888 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MX=42;
ll n,m,a[MX];
vector<ll>v1,v2;
void calc(int x,ll sum,int fin){
    if(x==fin){
        v1.push_back(sum);
        return;
    }
    calc(x+1,sum+a[x],fin);
    calc(x+1,sum,fin);
}
ll DP(ll x,ll sum){
    if(x==n){
        if(sum<=m)return 1;
        return 0;
    }
    ll ret=DP(x+1,sum);
    ret+=DP(x+1,sum+a[x]);
    return ret;
}
int main(){
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    calc(0,0,n/2+1);
    v2=v1;v1.clear();
    calc(n/2+1,0,n);
    ll ans=0;
    sort(v1.begin(),v1.end());
    for(auto pp:v2){
        if(!pp)continue;
        ll idx=upper_bound(v1.begin(),v1.end(),m-pp)-v1.begin();
        ans+=idx;
  //      cout<<pp<<" "<<m-pp<<" "<<idx<<endl;
    }
    for(auto pp:v1)ans+=(pp<=m);
    cout<<ans<<endl;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:26:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
                            ^
bobek.cpp:28:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
                            ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 480 KB Output is correct
2 Correct 1 ms 480 KB Output is correct
3 Correct 2 ms 656 KB Output is correct
4 Correct 2 ms 656 KB Output is correct
5 Correct 1 ms 656 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 1 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 688 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 728 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 2 ms 728 KB Output is correct
6 Correct 2 ms 740 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 1 ms 756 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 1 ms 760 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2936 KB Output is correct
2 Correct 124 ms 9116 KB Output is correct
3 Correct 581 ms 33868 KB Output is correct
4 Correct 120 ms 33868 KB Output is correct
5 Correct 13 ms 33868 KB Output is correct
6 Correct 6 ms 33868 KB Output is correct
7 Correct 10 ms 33868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 33868 KB Output is correct
2 Correct 27 ms 33868 KB Output is correct
3 Correct 263 ms 33868 KB Output is correct
4 Correct 2 ms 33868 KB Output is correct
5 Correct 7 ms 33868 KB Output is correct
6 Correct 14 ms 33868 KB Output is correct
7 Correct 9 ms 33868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 33868 KB Output is correct
2 Correct 151 ms 33868 KB Output is correct
3 Correct 153 ms 33868 KB Output is correct
4 Correct 1 ms 33868 KB Output is correct
5 Correct 44 ms 33868 KB Output is correct
6 Correct 194 ms 33872 KB Output is correct
7 Correct 47 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 320 ms 33872 KB Output is correct
2 Correct 24 ms 33872 KB Output is correct
3 Correct 11 ms 33872 KB Output is correct
4 Correct 2 ms 33872 KB Output is correct
5 Correct 7 ms 33872 KB Output is correct
6 Correct 137 ms 33872 KB Output is correct
7 Correct 9 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 33872 KB Output is correct
2 Correct 129 ms 33872 KB Output is correct
3 Correct 10 ms 33872 KB Output is correct
4 Correct 9 ms 33872 KB Output is correct
5 Correct 83 ms 33872 KB Output is correct
6 Correct 15 ms 33872 KB Output is correct
7 Correct 155 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 422 ms 33880 KB Output is correct
2 Correct 31 ms 33880 KB Output is correct
3 Correct 12 ms 33880 KB Output is correct
4 Correct 623 ms 33888 KB Output is correct
5 Correct 133 ms 33888 KB Output is correct
6 Correct 10 ms 33888 KB Output is correct
7 Correct 18 ms 33888 KB Output is correct