Submission #170976

# Submission time Handle Problem Language Result Execution time Memory
170976 2019-12-26T21:18:22 Z reda Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
930 ms 1048576 KB
#include<bits/stdc++.h>
#define endl '\n'
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long 
#define pb push_back
#define all(x) x.begin(),x.end()
#pragma GCC optimize ("Ofast","unroll-loops")
using namespace std;
const int MOD = 1e9+7;
const int MAXN = 50;
ll  ans  = 0 ;
ll  n, m ;
void solve(ll idx  ,  ll  sum , vector<ll> arr ,  vector<ll> &v  )
{
    if(idx==arr.size()-1 )
    {
    if(sum<=m)v.push_back(sum);
    	return ; 
    }
    solve(idx+1,sum,arr,v);
    solve(idx+1,sum+arr[idx],arr,v);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m ;
    vector<ll> a , b ;
    for(ll  i=1;i<=n;i++)
    {
    	ll x;
    	cin >> x ; 
    	if(i%2==0)
    	{
    	  a.push_back(x);
    	}
    	else
    	{
    	  b.push_back(x);
    	}
    }
    vector<ll> v1,v2;
    solve(0,0,a,v1);
    solve(0,0,b,v2);
    sort(all(v1));
    sort(all(v2));
    for(auto  it : v1)
    {
    	 ll l = 0 ;
    	 ll  r= v2.size()-1;
    	 ll  x = -1 ;
    	 while (l<=r)
    	 {
    	 	ll mid =(l+r)>>1;
    	 	if(v2[mid]+it<=m)
    	 	{
    	 		x=mid;
    	 		l=mid+1;
    	 	}
    	 	else r= mid-1;
    	 }
    	 if(x!=-1)ans+=(x+1);
    }
    cout<<ans<<endl;
    return 0 ;
}

Compilation message

bobek.cpp: In function 'void solve(long long int, long long int, std::vector<long long int>, std::vector<long long int>&)':
bobek.cpp:17:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(idx==arr.size()-1 )
        ~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 930 ms 1048576 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 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 26 ms 1264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 2032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 212 ms 6624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 292 ms 10588 KB Output isn't correct
2 Halted 0 ms 0 KB -