Submission #870257

#TimeUsernameProblemLanguageResultExecution timeMemory
870257vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
70 / 100
1070 ms300112 KiB
#include <iostream> #include <vector> #define int long long using namespace std; int n, m, res = 0; vector<int> a; void dfs(int i, int sum) { if(i == n) { res++; return; } if(sum+a[i] <= m) dfs(i+1, sum+a[i]); dfs(i+1, sum); } signed main() { cin >> n >> m; a = vector<int>(n); for(int i = 0; i < n; i++) cin >> a[i]; if(m > 1e6) { dfs(0, 0); } else { vector<vector<int>> dp(n+1, vector<int>(m+1)); dp[0][0] = 1; for(int i = 1; i <= n; i++) { for(int j = 0; j <= m; j++) { dp[i][j] = dp[i-1][j]+(j>=a[i-1] ? dp[i-1][j-a[i-1]] : 0); //cout << dp[i][j] << " "; } //cout << "\n"; } for(int i = 0; i <= m; i++) res+=dp[n][i]; } cout << res << "\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...