이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
int main()
{
ll n, m, i, j, ans = 0, sum = 0;
cin >> n >> m;
vl v(n), v1, v2, x, y;
for(i = 0; i < n; i++)
{
cin >> v[i];
if(i < (n + 1) / 2)
v1.pb(v[i]);
else
v2.pb(v[i]);
}
ll a = v1.size(), b = v2.size();
for(i = 0; i < 1 << a; i++)
{
sum = 0;
for(j = 0; j < a; j++)
{
if((i >> j) & 1)
sum += v1[j];
}
x.pb(sum);
}
for(i = 0; i < 1 << b; i++)
{
sum = 0;
for(j = 0; j < b; j++)
{
if((i >> j) & 1)
sum += v2[j];
}
y.pb(sum);
}
sort(all(x));
sort(all(y));
for(i = 0; i < x.size(); i++)
{
ll u = upper_bound(all(y), m - x[i]) - y.begin();
ans += u;
}
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
bobek.cpp: In function 'int main()':
bobek.cpp:49:18: 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]
49 | for(i = 0; i < x.size(); i++)
| ~~^~~~~~~~~~
# | 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... |