fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. int n, x, y;
  6. cin >> n >> x >> y;
  7. x--; y--;
  8. vector<long long> a(n);
  9. vector<int> b(n);
  10. for (int i = 0; i < n; i++) cin >> a[i];
  11. for (int i = 0; i < n; i++) cin >> b[i];
  12.  
  13. long long ax = a[x], ay = a[y], ans = ax*ay;
  14. int mi = b[x], mx = b[y];
  15. if (mi>mx) swap(mi,mx);
  16.  
  17. for (int i = 0; i < n; i++) {
  18. if (mi < b[i] && b[i] < mx) ans += a[i]*(ax+ay);
  19. }
  20. cout << ans << '\n';
  21. }
  22.  
  23. int main() {
  24. int t;
  25. cin >> t;
  26. while (t--) solve();
  27. }
  28.  
Success #stdin #stdout 0s 544KB
stdin
Standard input is empty
stdout
Standard output is empty