# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
473345 |
2021-09-15T12:31:21 Z |
Ahmed57 |
San (COCI17_san) |
C++14 |
|
1000 ms |
5432 KB |
#include<bits/stdc++.h>
using namespace std;
long long n,k;
vector<pair<long long,long long>> arr(50);
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>k;
for(int i = 0;i<n;i++){
long long a,b;cin>>a>>b;
arr[i] = {a,b};
}
arr[45]={0,0};
long long ans = 0;
map<int,vector<long long>> v;
for(long long mask=0;mask<(1<<n/2);mask++){
long long s=0,p=45,w=-1;
for(long long i=0;i<n/2;i++){
if((1<<i)&mask){
if(arr[i].first>=arr[p].first){
s+=arr[i].second;
}
else{
s=-1;
break;
}
w=i;
p=i;
}
}
v[w].push_back(s);
}
int u = n/2,w=n;
n=n-(n/2);
vector<pair<long long,long long>> cd(50);
for(int i = u;i<w;i++){
cd[i-u]={arr[i].first,arr[i].second};
}
cd[45]={0,0};
for(long long mask=0;mask<(1<<n);mask++){
long long s=0,p=45,j=-1;
for(long long i=0;i<n;i++){
if((1<<i)&mask){
if(cd[i].first>=cd[p].first){
s+=cd[i].second;
}
else{
s=-1;
break;
}
if(j==-1)j=i;
p=i;
}
}
for(;j<40;j++){
int y = lower_bound(v[j].begin(),v[j].end(),k-s)-v[j].begin();
if(y>0&&v[j][y-1]==k-s)y--;
ans+=((v[j].size()-1)-y)+1;
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
119 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
514 ms |
3136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
5432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |