fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. typedef long long ll;
  5.  
  6. int main() {
  7. int n; std::cin >> n;
  8. std::vector<int> t(n), a(n);
  9. for (auto& it : t) std::cin >> it;
  10. for (auto& it : a) std::cin >> it;
  11. int imin = -1; ll minsum = ll(1e18);
  12. for (int i = 0; i < n; ++i) {
  13. ll temp = ll(a[i]+1)*t[i];
  14. if (temp < minsum || (temp == minsum && a[imin] > a[i])) {
  15. minsum = temp;
  16. imin = i;
  17. }
  18. }
  19. std::cout << imin+1;
  20. return 0;
  21. }
Success #stdin #stdout 0s 4348KB
stdin
4
4 9 5 4 
1 7 5 2 
stdout
1