Submission #855154


Source Code Expand

Copy
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll dp[55][55][2505];
ll n,a;
ll x[55];
int main()
{
  finp;
  dp[0][0][0]=1;
  cin>>n>>a;
  afor(i,1,n)
  {
    cin>>x[i];
    afor(j,0,n)afor(k,0,2500)dp[i][j][k]=dp[i-1][j][k];

    afor(j,0,n-1)afor(k,0,2500)
    {
      if((k + x[i])>2500)break;
      dp[i][j+1][k+x[i]]+=dp[i-1][j][k];
    }
  }

  ll ans=0;
  afor(j,1,n)afor(k,0,2500)
  {
    if(k%j==0 && (k/j)==a)ans+=dp[n][j][k];
  }
  cout<<ans;
  
return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User fauzdar65
Language C++14 (GCC 5.4.1)
Score 300
Code Size 2028 Byte
Status AC
Exec Time 90 ms
Memory 50432 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 4
AC × 12
AC × 24
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt
All example_01.txt, example_02.txt, example_03.txt, example_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt
Case Name Status Exec Time Memory
example_01.txt AC 5 ms 640 KB
example_02.txt AC 4 ms 512 KB
example_03.txt AC 7 ms 1664 KB
example_04.txt AC 42 ms 22400 KB
subtask1_01.txt AC 14 ms 5632 KB
subtask1_02.txt AC 14 ms 5632 KB
subtask1_03.txt AC 14 ms 5632 KB
subtask1_04.txt AC 13 ms 5632 KB
subtask1_05.txt AC 14 ms 5632 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 14 ms 5632 KB
subtask1_09.txt AC 12 ms 4992 KB
subtask2_01.txt AC 89 ms 50432 KB
subtask2_02.txt AC 89 ms 50304 KB
subtask2_03.txt AC 88 ms 48384 KB
subtask2_04.txt AC 89 ms 50304 KB
subtask2_05.txt AC 89 ms 50304 KB
subtask2_06.txt AC 90 ms 50304 KB
subtask2_07.txt AC 89 ms 50304 KB
subtask2_08.txt AC 42 ms 22400 KB
subtask2_09.txt AC 42 ms 22400 KB
subtask2_10.txt AC 62 ms 34176 KB
subtask2_11.txt AC 67 ms 37504 KB