#include <bits/stdc++.h>
#define fi first
#define sc second
#define forn(i,p,k) for(int i=(p);i<=(k);++i)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MM=5013;
const int P=1000000007;
int dp[MM],T[MM],big=0;
inline int add(const int &a, const int &b) {return a+b>=P?a+b-P:a+b;}
inline void update(const int &x)
{
big=add(big,big);
for(int i=MM-1;i>=x-1;--i)
{
if(i+x>=MM) big=add(big,dp[i]);
else dp[i+x]=add(dp[i+x],dp[i]);
}
}
int main()
{
ios_base::sync_with_stdio(0);
dp[0]=1;
int n,wyn=0;
cin>>n;
forn(i,1,n) cin>>T[i];
sort(T+1,T+n+1);
forn(i,1,n) update(T[i]);
wyn=big;
forn(i,1,MM-1) wyn=add(wyn,dp[i]);
return cout<<wyn<<"\n",0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <bits/stdc++.h> #define fi first #define sc second #define forn(i,p,k) for(int i=(p);i<=(k);++i) #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MM=5013; const int P=1000000007; int dp[MM],T[MM],big=0; inline int add(const int &a, const int &b) {return a+b>=P?a+b-P:a+b;} inline void update(const int &x) { big=add(big,big); for(int i=MM-1;i>=x-1;--i) { if(i+x>=MM) big=add(big,dp[i]); else dp[i+x]=add(dp[i+x],dp[i]); } } int main() { ios_base::sync_with_stdio(0); dp[0]=1; int n,wyn=0; cin>>n; forn(i,1,n) cin>>T[i]; sort(T+1,T+n+1); forn(i,1,n) update(T[i]); wyn=big; forn(i,1,MM-1) wyn=add(wyn,dp[i]); return cout<<wyn<<"\n",0; } |
English