답안 #170977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170977 2019-12-26T21:24:12 Z reda Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
579 ms 21060 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() )
    {
    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() )
        ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 2032 KB Output is correct
2 Correct 144 ms 5448 KB Output is correct
3 Correct 569 ms 21060 KB Output is correct
4 Correct 143 ms 5476 KB Output is correct
5 Correct 29 ms 1660 KB Output is correct
6 Correct 14 ms 1016 KB Output is correct
7 Correct 18 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 2924 KB Output is correct
2 Correct 49 ms 2032 KB Output is correct
3 Correct 244 ms 10604 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 12 ms 1020 KB Output is correct
6 Correct 33 ms 1704 KB Output is correct
7 Correct 18 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 3604 KB Output is correct
2 Correct 201 ms 6628 KB Output is correct
3 Correct 202 ms 6624 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 151 ms 6624 KB Output is correct
6 Correct 518 ms 20928 KB Output is correct
7 Correct 99 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 12880 KB Output is correct
2 Correct 49 ms 2032 KB Output is correct
3 Correct 16 ms 1016 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 13 ms 1016 KB Output is correct
6 Correct 397 ms 12740 KB Output is correct
7 Correct 18 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 2028 KB Output is correct
2 Correct 144 ms 5484 KB Output is correct
3 Correct 15 ms 1012 KB Output is correct
4 Correct 15 ms 1016 KB Output is correct
5 Correct 157 ms 6652 KB Output is correct
6 Correct 48 ms 2028 KB Output is correct
7 Correct 258 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 567 ms 20860 KB Output is correct
2 Correct 50 ms 2036 KB Output is correct
3 Correct 15 ms 1016 KB Output is correct
4 Correct 579 ms 20996 KB Output is correct
5 Correct 213 ms 10588 KB Output is correct
6 Correct 34 ms 1580 KB Output is correct
7 Correct 36 ms 376 KB Output is correct