Submission #766361

#TimeUsernameProblemLanguageResultExecution timeMemory
766361a_aguiloIce Hockey World Championship (CEOI15_bobek)C++14
70 / 100
66 ms7380 KiB
#include<bits/stdc++.h> using namespace std; int N; long long M; long long cost[40]; void smallM(){ vector<long long int> dp(M+1, 0); dp[0] = 1; for(int match = 0; match < N; ++match){ for(long long val = M; val > 0; --val){ if(cost[match] <= val) dp[val] += dp[val - cost[match]]; } } long long ans = 0; for(int i = 0; i <= M; ++i) ans += dp[i]; cout << ans << endl; } int main(){ cin >> N >> M; for(int i = 0; i < N; ++i) cin >> cost[i]; if(N <= 20){ long long ans = 0; for(int mask = 0; mask < (1 << N); ++mask){ long long sum = 0; for(int i = 0; i < N; ++i){ if(mask & (1 << i))sum+= cost[i]; } if(sum <= M) ans++; } cout << ans << endl; }else{ smallM(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...