Submission #870271

#TimeUsernameProblemLanguageResultExecution timeMemory
870271vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
70 / 100
66 ms7580 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n,m; cin >> n >> m; vector <int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; if (m <= 1000000) { vector <int> dp(m+1,0); dp[0] = 1; for (int i = 0; i < n; i++) for (int j = m; j >= a[i]; j--) dp[j] += dp[j-a[i]]; int cnt = 0; for (int i = 0; i <= m; i++) cnt+=dp[i]; cout << cnt << '\n'; } else { int cnt = 0; for (int i = 0; i < (1<<n); i++) { int sum = 0; for (int j = 0; j < n; j++) if ((1<<j)&i) sum+=a[j]; if (sum <= m) cnt++; } cout << cnt << '\n'; } }
#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...