이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define vvi vector<vector<int>>
#define ld long double
#define ar array
#define pb push_back
#define vi vector<int>
#define vc vector
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define all(c) (c).begin(), (c).end()
#define endll '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
#define lb(a, x) lower_bound(all(a), x) - a.begin();
#define ub(a, x) upper_bound(all(a), x) - a.begin();
template<typename T> bool umax(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool umin(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
mt19937 rng(time(0));
const int sz = 5e5 + 5;
void solve() {
int n, m;
cin >> n >> m;
vi v1, v2;
for(int i = 0; i < n; ++i){
int x;
cin >> x;
if(i < 20){
v1.pb(x);
}else{
v2.pb(x);
}
}
vector<int>a;
int res = 0;
for(int i = 0; i < (1 << v1.size()); ++i){
int s = 0;
for(int j = 0; j < v1.size(); ++j){
if((1 << j) & i){
s += v1[j];
}
}
if(s <= m){
a.pb(s);
}
}
sort(all(a));
for(int i = 0; i < (1 << v2.size()); ++i){
int s = 0;
for(int j = 0; j < v2.size(); ++j){
if((1 << j) & i){
s += v2[j];
}
}
res += upper_bound(all(a), m - s) - a.begin();
}
cout << res << endl;
}
signed main() {
fastio
int T = 1;
while (T--) {
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
bobek.cpp: In function 'void solve()':
bobek.cpp:46:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int j = 0; j < v1.size(); ++j){
| ~~^~~~~~~~~~~
bobek.cpp:58:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int j = 0; j < v2.size(); ++j){
| ~~^~~~~~~~~~~
# | 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... |