답안 #40670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40670 2018-02-06T17:39:19 Z MatheusLealV Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
619 ms 17596 KB
#include <bits/stdc++.h>
#define N 41
using namespace std;
typedef long long ll;

ll n, v[N], ans, k;

vector<ll> val;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>k;

	for(int i = 0; i < n; i++) cin>>v[i];

    int m = n/2;

    for(int mask = 1; mask <= ( (1<<(m + 1)) - 1) ; mask ++)
    {
        ll sum = 0;

        for(int i = 0; i <= m; i++)
        {
            if( (mask & (1<<i)) )
            {
                sum += v[i];
            }
        }

        if(sum <= k) ans ++;

        val.push_back(sum);
    }

    sort(val.begin(), val.end());

    for(int mask = 1; mask <= ( (1<<(n - m - 1)) - 1) ; mask ++)
    {
    	ll sum = 0;

        for(int i = m + 1; i < n; i++)
        {
            int j = i - m - 1;

        	if( (mask & (1<<j)) )
        	{
        		sum += v[i];
        	}
        }

       if(sum <= k)
       {
       		//cout<<sum<<" "<< (upper_bound(val.begin(), val.end(), k - sum) - val.begin())<<"\n";
       		ans += upper_bound(val.begin(), val.end(), k - sum) - val.begin() + 1;
       }
    }

    cout<<ans + 1<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 628 KB Output is correct
6 Correct 2 ms 652 KB Output is correct
7 Correct 2 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 820 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 836 KB Output is correct
4 Correct 1 ms 836 KB Output is correct
5 Correct 1 ms 836 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 836 KB Output is correct
2 Correct 2 ms 836 KB Output is correct
3 Correct 1 ms 836 KB Output is correct
4 Correct 1 ms 836 KB Output is correct
5 Correct 2 ms 836 KB Output is correct
6 Correct 1 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 1952 KB Output is correct
2 Correct 141 ms 4976 KB Output is correct
3 Correct 599 ms 17292 KB Output is correct
4 Correct 141 ms 17292 KB Output is correct
5 Correct 22 ms 17292 KB Output is correct
6 Correct 13 ms 17292 KB Output is correct
7 Correct 24 ms 17292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 17292 KB Output is correct
2 Correct 38 ms 17292 KB Output is correct
3 Correct 268 ms 17292 KB Output is correct
4 Correct 1 ms 17292 KB Output is correct
5 Correct 11 ms 17292 KB Output is correct
6 Correct 26 ms 17292 KB Output is correct
7 Correct 25 ms 17292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 17292 KB Output is correct
2 Correct 182 ms 17292 KB Output is correct
3 Correct 167 ms 17292 KB Output is correct
4 Correct 2 ms 17292 KB Output is correct
5 Correct 99 ms 17292 KB Output is correct
6 Correct 439 ms 17596 KB Output is correct
7 Correct 117 ms 17596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 17596 KB Output is correct
2 Correct 38 ms 17596 KB Output is correct
3 Correct 16 ms 17596 KB Output is correct
4 Correct 1 ms 17596 KB Output is correct
5 Correct 13 ms 17596 KB Output is correct
6 Correct 259 ms 17596 KB Output is correct
7 Correct 24 ms 17596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 17596 KB Output is correct
2 Correct 132 ms 17596 KB Output is correct
3 Correct 14 ms 17596 KB Output is correct
4 Correct 14 ms 17596 KB Output is correct
5 Correct 126 ms 17596 KB Output is correct
6 Correct 30 ms 17596 KB Output is correct
7 Correct 441 ms 17596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 579 ms 17596 KB Output is correct
2 Correct 39 ms 17596 KB Output is correct
3 Correct 17 ms 17596 KB Output is correct
4 Correct 619 ms 17596 KB Output is correct
5 Correct 188 ms 17596 KB Output is correct
6 Correct 26 ms 17596 KB Output is correct
7 Correct 49 ms 17596 KB Output is correct