#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long n,k,a[44],b[44],nm,ans;
vector<pair<long long,long long> >on;
vector<long long>to[44];
vector<long long>cal;
map<long long,long long>mp;
void bt(int x,int y,int mx,long long sum)
{
if(y==mx+1)
{
if(sum>=k)ans++;
if(sum>0)
{
if(mx==n/2)on.push_back({a[x],sum});
else to[mp[a[x]]].push_back(sum);
}
return;
}
if(a[x]<=a[y])bt(y,y+1,mx,sum+b[y]);
bt(x,y+1,mx,sum);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("gpsduel.in","r",stdin);
//freopen("gpsduel.out","w",stdout);
cin>>n>>k;
for(int i=1; i<=n; i++)
{
cin>>a[i]>>b[i];
cal.push_back(a[i]);
}
sort(cal.begin(),cal.end());
for(int i=0;i<cal.size();i++)
{
if(mp[cal[i]]==0)mp[cal[i]]=++nm;
}
bt(0,1,n/2,0);
bt(0,(n/2)+1,n,0);
for(int i=0;i<n;i++)sort(to[i].begin(),to[i].end());
sort(on.begin(),on.end());
for(int i=0;i<on.size();i++)
{
int x=on[i].first,y=on[i].second;
for(int j=0;j<n;j++)
{
int cl=mp[cal[j]];
if(mp[x]>cl)continue;
int num=lower_bound(to[cl].begin(),to[cl].end(),k-y)-to[cl].begin();
ans+=(to[cl].size())-num;
}
}
cout<<ans;
}
Compilation message
san.cpp: In function 'int main()':
san.cpp:38:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<cal.size();i++)
~^~~~~~~~~~~
san.cpp:46:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<on.size();i++)
~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
1396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
63 ms |
2672 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
424 ms |
10804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |