#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SIZE(x) (int)(x).size()
#define ff first
#define ss second
inline ll readi(){
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int N;
ll K, ans;
int H[40], G[40];
int main(){
N=readi(), K=readi();
for(int i=0; i<N; i++){
H[i]=readi();
G[i]=readi();
}
for(int mask=0; mask<(1<<N); mask++){
int last=-1;
ll sum=0;
bool ok=1;
for(int i=0; i<N; i++){
if((mask>>i)&1){
if(H[i]<last){
ok=0;
break;
}
last=H[i];
sum+=G[i];
}
}
if(ok && sum>=K){
ans++;
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2016 KB |
Output is correct |
2 |
Correct |
0 ms |
2016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
2016 KB |
Output is correct |
2 |
Correct |
16 ms |
2016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |