Submission #956475

#TimeUsernameProblemLanguageResultExecution timeMemory
956475underwaterkillerwhaleMagneti (COCI21_magneti)C++17
110 / 110
151 ms143072 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int mod2=1e9+7;
const int  mod1=998244353;
struct ib
{
    int a;
    int b;
};
struct icd
{
    int a,b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
int n,m,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int  i,s10,s12;
int el=29;
main()
{
//#ifndef ONLINE_JUDGE
    // fin(task),fou(task);
//#endif
    NHP
//modwwe
    //  cin>>res;
    phongbeo(),down
    checktime
}
int dp[51][51][10001], a[51],c[10055][55];
ll C(int n, int k){
    if(n == k || k == 0) return 1;
    if(k > n) return 0;
    if(c[n][k] != -1) return c[n][k];
    return c[n][k] = (C(n - 1, k) + C(n - 1, k - 1)) % mod2;
}
void phongbeo()
{
 cin>>n>>k;
 for(int i=1;i<=n;i++)
     cin>>a[i];
     sort(a+1,a+1+n);
     dp[1][1][1]=1;
         memset(c, -1, sizeof c);
for(int i=2;i<=n;i++)
    for(int j=1;j<=i;j++)
    for(int z=1;z<=k;z++)
        {
             dp[i][j][z]=(dp[i-1][j-1][z-1]*j)%mod2;
              if(z>=a[i]){
                 dp[i][j][z]+=dp[i-1][j][z-a[i]]*2*j%mod2,
                 dp[i][j][z]%=mod2;}
               if(z>=a[i]*2-1){
                    dp[i][j][z] += (dp[i - 1][j + 1][z- a[i] * 2 + 1] *  j % mod2)  % mod2,
                    dp[i][j][z]%=mod2;}

        }
s2=0;
    for(int i = 1; i <= k; ++i){
        s2 += dp[n][1][i] * C(k - i + n, n) % mod2;
        s2 %= mod2;
    }
    cout << s2;
}

Compilation message (stderr)

Main.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main()
      | ^~~~
Main.cpp: In function 'void phongbeo()':
Main.cpp:61:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   61 |  for(int i=1;i<=n;i++)
      |  ^~~
Main.cpp:63:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   63 |      sort(a+1,a+1+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...