이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll sus[41];
int main(){
ll a,b,n,m;
map<ll, ll> aa, bb;
cin >> n >> m;
FOR(i,0,n) cin >> sus[i];
a = n/2;
b = (n-1)/2 + 1;
FOR(i,0,1<<a){
ll cur = 0, temp = 0, tempi = i;
while (tempi){
if (tempi&1) temp += sus[cur];
cur++;
tempi /=2;
}
aa[temp] += 1;
}
FOR(i,0,1<<b){
ll cur = a, temp = 0, tempi = i;
while (tempi){
if (tempi&1) temp += sus[cur];
cur++;
tempi /=2;
}
bb[temp] += 1;
}
vector<ll> aaa, bbb;
vector<ll> aaa2,bbb2;
ll cur = 0;
for (auto&i : aa){
aaa.push_back(i.first);
aaa2.push_back(i.second);
}
cur = 0;
for (auto&i : bb){
cur += i.second;
bbb.push_back(i.first);
bbb2.push_back(cur);
}
ll ans = 0;
FOR(i,0,aaa.size()){
if (m-aaa[i] < 0) continue;
ll lower = upper_bound(bbb.begin(), bbb.end(), m-aaa[i]) - bbb.begin() - 1;
ans += bbb2[lower] * aaa2[i];
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
bobek.cpp: In function 'int main()':
bobek.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
70 | FOR(i,0,aaa.size()){
| ~~~~~~~~~~~~~~
bobek.cpp:70:2: note: in expansion of macro 'FOR'
70 | FOR(i,0,aaa.size()){
| ^~~
# | 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... |