fork(3) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. struct iii{ int w,v,id; };
  5. int n,m,L,R,sum(0),ans[33];
  6. vector <int> res; iii a[33];
  7. bool cmp(iii x,iii y){ return x.v<y.v; }
  8. bool check(int d){ return (n==20&&d<8)||(n==25&&d<19)||(n==29&&d<10); }
  9. void dq(int i,int wei,int val,int d){
  10. if (val<sum&&L<=wei&&wei<=R){
  11. if (check(d)) return;
  12. sum=val; m=0;
  13. for(auto x:res) ans[++m]=x;
  14. }
  15. for(int j=i; j<=n; j++)
  16. if (a[j].v+val>sum) return; else
  17. if (wei+a[j].w<=R){
  18. res.push_back(a[j].id);
  19. dq(j+1,wei+a[j].w,val+a[j].v,d+1);
  20. res.pop_back();
  21. }
  22. }
  23. int32_t main(){
  24. /* Châu Nhật Tăng Dễ Thương Đáng Yêu */
  25. ios_base::sync_with_stdio(NULL);
  26. cin.tie(NULL); cout.tie(NULL);
  27. cin>>n>>L>>R;
  28. for(int i=1; i<=n; i++){
  29. int x,y; cin>>x>>y;
  30. a[i]={x,-y,i};
  31. }
  32. sort(a+1,a+n+1,cmp); dq(1,0,0,0);
  33. sort(ans+1,ans+m+1); cout<<m<<"\n";
  34. for(int i=1; i<=m; i++) cout<<ans[i]<<"\n";
  35. }
  36.  
Success #stdin #stdout 0.01s 5520KB
stdin
Standard input is empty
stdout
0