fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define st first
  4. #define nd second
  5. int main() {
  6. ios::sync_with_stdio(false);
  7. cin.tie(0); cout.tie(0);
  8. long long n,d,l,r,cnt=0; cin >> n >> d >> l >> r;
  9. pair <long long,int> a[n+1];
  10. for(int i=1;i<=n;i++) {
  11. long long u,v; cin >> u >> v;
  12. a[i].st=l*u+v*r;
  13. a[i].nd=i;
  14. }
  15. sort(a+1,a+n+1);
  16. vector <int> v;
  17. for(int i=1;i<=n;i++) {
  18. if(a[i].st>d) break;
  19. cnt++, v.push_back(a[i].nd), d-=a[i].st;
  20. }
  21. cout << cnt << '\n';
  22. for(auto x:v) cout << x << ' ';
  23. return 0;
  24. }
Success #stdin #stdout 0s 5288KB
stdin
3 10
2 3
1 4
2 1
1 0
stdout
2
3 2