#include<bits/stdc++.h>
#define endl '\n'
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#pragma GCC optimize ("Ofast","unroll-loops")
using namespace std;
const int MOD = 1e9+7;
const int MAXN = 50;
ll ans = 0 ;
ll n, m ;
void solve(ll idx , ll sum , ll arr[] , vector<ll> &v , ll k )
{
if(sum>m || idx>k)return ;
if(idx==k && sum<=m)v.push_back(sum);
solve(idx+1,sum,arr,v,k);
solve(idx+1,sum+arr[idx],arr,v,k);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m ;
ll arr[n+1];
int i = 1 ;
while(cin>>arr[i])
{
i++;
if(i==n/2)break;
}
vector<ll> v1,v2;
solve(1,0,arr,v1,i);
i = 1 ;
while(cin>>arr[i])
{
i++;
}
solve(1,0,arr,v2,i);
sort(all(v1));
sort(all(v2));
i = 0 ;ll j = 0 ;
while(i<v1.size()&&j<v2.size())
{
if(v1[i]+v2[j]>m)break;
while(v1[i]+v2[j]<=m)j++;
ans+=j+1;
i++;
}
for(int i = 0 ;i < v2.size();i++)
{
ans+=(v2[i]<=m);
}
for(int i = 0 ;i < v1.size();i++)
{
ans+=(v1[i]<=m);
}
cout<<(ans-1)/2<<endl;
return 0 ;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:45:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(i<v1.size()&&j<v2.size())
~^~~~~~~~~~
bobek.cpp:45:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(i<v1.size()&&j<v2.size())
~^~~~~~~~~~
bobek.cpp:52:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ;i < v2.size();i++)
~~^~~~~~~~~~~
bobek.cpp:56:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ;i < v1.size();i++)
~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
5480 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
37 ms |
5996 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
76 ms |
9976 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
316 ms |
38204 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
5352 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
360 ms |
42436 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |