# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1241205 | _dtq_ | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 409 ms | 8624 KiB |
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(x) (ll)(x.size())
#define all(v) v.begin(), v.end()
#define sz(x) (ll)(x.size())
#define se second
#define fi first
using namespace std;
const ll N = 50;
ll n, i, k, a[N];
int main()
{
#define TN ""
if (fopen(TN ".inp", "r"))
{
freopen(TN ".inp", "r", stdin);
freopen(TN ".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k;
for( i = 1; i <= n; i ++ )
cin >> a[i];
ll x = n / 2, y = n - x;
vector<ll>vec;
for( i = 0; i < (1 << y); i ++ )
{
ll sum = 0;
for( int w = 0; w < y; w ++ )
if(i & (1 << w)) sum += a[w + 1 + x];
vec.pb(sum);
}
sort(all(vec));
ll ans = 0;
for( i = 0; i < (1 << x); i ++ )
{
ll sum = 0;
for( int w = 0; w < x; w ++ )
if(i & (1 << w)) sum += a[w + 1];
if(sum > k) continue;
ll vt = upper_bound(all(vec), k - sum) - vec.begin() - 1;
ans += (vt + 1);
}
cout << ans;
return 0;
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |