Submission #1005006

#TimeUsernameProblemLanguageResultExecution timeMemory
1005006ereringIce Hockey World Championship (CEOI15_bobek)C++17
50 / 100
444 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define ll long long #define int long long const long long inf=1e18; const int MOD=1e9+7; const int N=41; int a[N],n,m,ans=0; void func(int i,int score){ if(i==n){ ans++; return; } func(i+1,score); if(score+a[i]<=m)func(i+1,score+a[i]); } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m; for(int i=0;i<n;i++)cin>>a[i]; if(n<=20)func(0,0); else{ int dp[n][m+1]; for(int j=0;j<=m;j++)dp[0][j]=0; dp[0][0]=1; dp[0][a[0]]=1; for(int i=1;i<n;i++){ for(int j=0;j<=m;j++){ if(j>a[i] && dp[i-1][j-a[i]]>0)dp[i][j]=dp[i-1][j-a[i]]+dp[i-1][j]; else dp[i][j]=dp[i-1][j]; if(j==a[i])dp[i][j]++; } } for(int j=0;j<=m;j++){ ans+=dp[n-1][j]; } } cout<<ans; }
#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...