#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 40;
ll N,M;
vector<ll> lv,rv;
vector<ll> la,ra;
void calc(vector<ll> &v,vector<ll>& all){
for(int i = 0;i<(1<<v.size());i++){
ll sum = 0;
for(int j = 0;j<v.size();j++){
if(i&(1<<j))sum += v[j];
}
all.push_back(sum);
}
sort(all.begin(),all.end());
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 0;i<N/2;i++){
ll k;
cin>>k;
la.push_back(k);
}
for(int i = N/2;i<N;i++){
ll k;
cin>>k;
ra.push_back(k);
}
calc(la,lv);
calc(ra,rv);
ll pt = 0;
ll ans = 0;
reverse(lv.begin(),lv.end());
for(auto &i:lv){
while(pt<rv.size()&&rv[pt]+i<=M)pt++;
ans += pt;
}
cout<<ans<<'\n';
return 0;
}
Compilation message
bobek.cpp: In function 'void calc(std::vector<long long int>&, std::vector<long long int>&)':
bobek.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int j = 0;j<v.size();j++){
| ~^~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:48:11: 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]
48 | while(pt<rv.size()&&rv[pt]+i<=M)pt++;
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
452 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1888 KB |
Output is correct |
2 |
Correct |
69 ms |
5420 KB |
Output is correct |
3 |
Correct |
290 ms |
20812 KB |
Output is correct |
4 |
Correct |
68 ms |
5460 KB |
Output is correct |
5 |
Correct |
12 ms |
1500 KB |
Output is correct |
6 |
Correct |
7 ms |
1028 KB |
Output is correct |
7 |
Correct |
15 ms |
1756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
3028 KB |
Output is correct |
2 |
Correct |
24 ms |
2140 KB |
Output is correct |
3 |
Correct |
122 ms |
12216 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
992 KB |
Output is correct |
6 |
Correct |
15 ms |
1756 KB |
Output is correct |
7 |
Correct |
16 ms |
2008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
3676 KB |
Output is correct |
2 |
Correct |
105 ms |
6948 KB |
Output is correct |
3 |
Correct |
106 ms |
7240 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
74 ms |
7124 KB |
Output is correct |
6 |
Correct |
255 ms |
20920 KB |
Output is correct |
7 |
Correct |
103 ms |
7536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
215 ms |
12860 KB |
Output is correct |
2 |
Correct |
24 ms |
2144 KB |
Output is correct |
3 |
Correct |
8 ms |
992 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
1112 KB |
Output is correct |
6 |
Correct |
208 ms |
13520 KB |
Output is correct |
7 |
Correct |
15 ms |
1500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
2140 KB |
Output is correct |
2 |
Correct |
68 ms |
5464 KB |
Output is correct |
3 |
Correct |
8 ms |
1112 KB |
Output is correct |
4 |
Correct |
8 ms |
1116 KB |
Output is correct |
5 |
Correct |
74 ms |
6992 KB |
Output is correct |
6 |
Correct |
23 ms |
2140 KB |
Output is correct |
7 |
Correct |
284 ms |
20880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
285 ms |
20816 KB |
Output is correct |
2 |
Correct |
24 ms |
2020 KB |
Output is correct |
3 |
Correct |
8 ms |
1116 KB |
Output is correct |
4 |
Correct |
302 ms |
21064 KB |
Output is correct |
5 |
Correct |
97 ms |
11200 KB |
Output is correct |
6 |
Correct |
16 ms |
1500 KB |
Output is correct |
7 |
Correct |
31 ms |
2792 KB |
Output is correct |