fork(9) download
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3. # define vi vector < int >
  4. # define pb push_back
  5. int a[1 << 20];
  6. int b[1 << 20];
  7. int p[1 << 20];
  8. int main(void)
  9. {
  10. int n;
  11. scanf("%d",&n);
  12. for (int i = 1;i <= n;++i)
  13. scanf("%d",&a[i]);
  14. for (int i = 1;i <= n;++i)
  15. scanf("%d",&b[i]);
  16. for (int i = 1;i <= n;++i)
  17. p[i] = i;
  18. sort(p + 1,p + 1 + n,[&](int xx,int yy) {return a[xx] > a[yy];});
  19. vi answer;
  20. answer.pb(p[1]);
  21. for (int i = 2;i <= n;i += 2)
  22. {
  23. int bst = p[i];
  24. if (i + 1 <= n && b[p[i + 1]] > b[bst])
  25. bst = p[i + 1];
  26. answer.pb(bst);
  27. }
  28. int sz = answer.size();
  29. printf("%d\n",sz);
  30. for (int i = 0;i < sz;++i)
  31. printf("%d%c",answer[i]," \n"[i == sz - 1]);
  32. cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
  33. return 0;
  34. }
  35.  
Runtime error #stdin #stdout 0s 27528KB
stdin
Standard input is empty
stdout
Standard output is empty