이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |