Submission #170992

# Submission time Handle Problem Language Result Execution time Memory
170992 2019-12-27T00:25:51 Z bloopie Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
232 ms 20820 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 41;
unordered_map<ll,ll> memo[MAXN];
unordered_map<ll,ll> memo2[MAXN];
int n;
ll mm;
ll a[MAXN];
ll b[MAXN];
int n1,n2;
vector<ll> p1,p2;
void solve1(int i,ll m)
{
    if(m > mm)
       return;
    if(i == n1)
      {
          p1.push_back(m);
          return;
      }
    
   solve1(i + 1 , m);
   solve1(i + 1 , m + a[i]);
}

void solve2(int i,ll m)
{
    if(m > mm)
       return ;
    if(i == n2)
      {
          p2.push_back(m);
          return;
      }
    
   solve2(i + 1 , m);
   solve2(i + 1 , m + b[i]);
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> mm;
    n1 = n / 2;
    n2 = n - n / 2;
    for(int i = 0 ; i < n1 ; i++)
       cin >> a[i];
    for(int i = 0 ; i < n2 ; i++)
       cin >> b[i];
    
    solve1(0,0);
    solve2(0,0);
    sort(p1.begin(),p1.end());
    sort(p2.begin(),p2.end());
    ll ans = 0;
    for(int i = 0 ; i < n1 ; i++)
     {
         //++ans;
         auto idx = upper_bound(p2.begin(),p2.end(),mm - p1[i]) - p2.begin();
         ans+=idx;
     }
     cout << ans ;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 3568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 12760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 2036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 20820 KB Output isn't correct
2 Halted 0 ms 0 KB -