#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("popcnt")
#define int long long
#define ll long long
#define endl '\n'
#define debug(...) printf(__VA_ARGS__)
//#define debug(...)
#define trace(x) cout<<#x<<"="<<x<<endl;
//#define trace(x)
#define vi vector<int>
#define vpii vector<pair<int,int> >
#define umap unordered_map
#define uset unordered_set
#define mk make_pair
#define pb push_back
#define pob pop_back
#define _ <<' '<<
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
void read(vector<int>& x){for (auto& zu: (x)) cin >> zu;}
static inline int read(){
int x = 0;char ch = getchar();
while (ch < '0' || ch>'9') ch = getchar();
while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
return x;
}
static inline void print(const int &x) {
if (x > 9)print(x / 10);
putchar('0' + x % 10);
}
#define F first
#define S second
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define mustawa ios::sync_with_stdio(false);cin.tie(nullptr);
#define pii pair<int,int>
#define mishari main
const int inf=1e9+7;
void fa(bool ok){ cout << (ok ? "Yes": "No") << endl;}
int pw(ll a,ll b,ll mod=1e9+7){
ll result = 1;
while(b) {
if(b&1) {
result = (result*a)%mod;
}
a = (a * a) % mod;
b>>=1;
}
return result;
}
inline void usaco(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}int ans,n,m;
vi v;
int f(int i=0,int cost=0){
if(i==n)return (cost<=m);
if(cost>m)return 0;
return f(i+1,cost+v[i])+f(i+1,cost);
}
void solve() {
cin>>n>>m;
v.resize(n);
read(v);
cout<<f();
}
signed mishari(){
mustawa;
//usaco("barnpainting");
int tescases = 1;
//cin>>tescases;
for(int i=1; i <= tescases; i++){
//cout<<"Case "<<i<<":"<<endl;
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 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 |
452 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 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 |
2 ms |
452 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 |
Execution timed out |
1035 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1030 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1040 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1068 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1027 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |