fork download
  1. /*
  2. My fast heart is beating my soul cut and bleeding
  3. My hells are too meeting with the man inside my brain
  4. I tell him the all as I stand and I fall
  5. And just to top it all I pay him for the task
  6. My guts I am spilling I tell of the killings
  7. With me at top billing I take off the mask
  8. His jaw starts a dropping I say there's no stopping
  9. The blood I'll be mopping right there on his couch
  10. Another time he'll ask me what it is I'm thinking
  11. And I will have to show him I long to see him dead
  12. The walls dripping red from the axe in his head
  13. And I'm sure now he's dead by the look in his eyes
  14. Put me to sleep and hypnotize see the dead stare in my eyes
  15. Let your guard down when you try to get inside my head
  16. Dive in deep into my mind wonder all the things you'll find
  17. A war is up your death is signed session over-dead
  18. I think I'm starting to go crazy over wanting to kill
  19. I think I'll never stop the craving to see blood start to spill
  20. I see the outcome when your heart stops beating and I start to sweat
  21. I love the moment when you're dead but haven't taken your last breath
  22. The cops busting in in the middle of my sin
  23. I stop and start to grin as I see the bodies fly
  24. In my mind I kill them all heads will roll and bodies fall
  25. Blood and guts and that is all that you can recognize
  26. I come back from a daydream open eyes and start to scream
  27. What does all this gore mean is it really real or not
  28. Splash my face and rub my eyes maybe noone really dies
  29. Open up to realize its all inside my head
  30. I think I'm starting to go crazy over wanting to kill
  31. I think I'll never stop the craving to see blood start to spill
  32. I see the outcome when your heart stops beating and I start to sweat
  33. I love the moment when you're dead but haven't taken your last breath
  34. I think I'm starting to go crazy over wanting to kill
  35. I think I'll never stop the craving to see blood start to spill
  36. I think I'm starting to go crazy over wanting to kill
  37. I think I'll never stop the craving to see blood start to spill
  38. I see the outcome when your heart stops beating and I start to sweat
  39. I love the moment when you're dead but haven't taken your last breath yet
  40. */
  41.  
  42. #include <bits/stdc++.h>
  43.  
  44. #define ll long long int
  45. #define pb push_back
  46. #define PI acos(-1.0)
  47. #define pll pair<ll,ll>
  48. #define V vector
  49. #define F first
  50. #define S second
  51.  
  52. using namespace std;
  53.  
  54. void solve(){
  55. ll n, d;
  56. cin >> n >> d;
  57. V<ll> a(n), b(n);
  58. for(int i = 0; i < n; i++)
  59. cin >> a[i];
  60. for(int i = 0; i < n; i++)
  61. cin >> b[i];
  62. ll res = -1e18;
  63. ll x = log2(2*n*d);
  64. for(ll j = n-1; j >= max(0ll,n-x); j--){
  65. for(ll i = 0; i <= j; i++){
  66. if(a[i] <= j+1){
  67. res = max(res, (i+1)*(j+1) - d*(b[i]^b[j]));
  68. }
  69. }
  70. }
  71. cout << res << endl;
  72. }
  73.  
  74. int main(){
  75. cin.tie(0)->sync_with_stdio(0); cout.tie(0);
  76. int T = 1;
  77. cin >> T;
  78. for(int i = 1; i <= T; i++){
  79. //cout << "Case #" << i << ": ";
  80. solve();
  81. }
  82. return 0;
  83. }
  84.  
  85.  
  86.  
Success #stdin #stdout 0.01s 5348KB
stdin
1
5 1
2 3 5 5 6
2 2 2 4 3
stdout
14