#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define ll long long
const int N = 25;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9+7;
int h[N];
ll g[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
ll k;
ll ans = 0;
cin>>n>>k;
for(int i=0;i<n;i++) {
cin>>h[i]>>g[i];
}
for(int i=1;i<(1<<n);i++) {
int hmax=0;
ll sum = 0;
int cnt=0;
for(int j=0;j<n;j++) {
if(i&(1<<j)) {
if(h[j]<hmax) break;
else hmax=h[j];
sum+=g[j];
}
cnt++;
}
if(sum>=k&&cnt==n) ans++;
}
cout<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
576 KB |
Output is correct |
2 |
Correct |
19 ms |
576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |