given a 2d(N*N) matrix...N<=5*10^3 ...maximize F(a,b,c,d)=A[a][b]+A[c][d] -|a-c|-|b-d| ...0<=A[i][j]<=10^9. output max value of F for (a,b) not equal to (c,d) i.e. 2 distinct points. i was only able to think of bruteforce hence TLEd :(

# | User | Rating |
---|---|---|

1 | tourist | 3707 |

2 | Benq | 3672 |

3 | Radewoosh | 3627 |

4 | ksun48 | 3547 |

5 | Miracle03 | 3480 |

6 | ecnerwala | 3400 |

7 | peehs_moorhsum | 3384 |

8 | maroonrk | 3361 |

9 | sunset | 3338 |

10 | Um_nik | 3320 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 209 |

2 | Um_nik | 196 |

3 | YouKn0wWho | 192 |

4 | Errichto | 182 |

5 | awoo | 181 |

6 | sus | 180 |

7 | tourist | 175 |

8 | -is-this-fft- | 171 |

8 | SecondThread | 171 |

10 | Radewoosh | 170 |

given a 2d(N*N) matrix...N<=5*10^3 ...maximize F(a,b,c,d)=A[a][b]+A[c][d] -|a-c|-|b-d| ...0<=A[i][j]<=10^9. output max value of F for (a,b) not equal to (c,d) i.e. 2 distinct points. i was only able to think of bruteforce hence TLEd :(

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/20/2021 07:55:34 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

please help in finding the correct approach :D

Here is another problem from the same contest which I am unable to figure out:

X and Y are playing a game on a given array with n elements. X removes an element from the array. Y removes the element at the middle position of the remaining array. This game continues till no elements remain. Maximize the elements picked by X. And output the sum of the elements of X.

Constraints:Input Formatn followed by n spaced integers denoting the n elements of the given array.

Output FormatA single number denoting the maximum sum of elements X can get to

Sample Input 1:4

1 2 3 4

Sample Output 1:7

Sample Input 2:4

5 15 10 5

Sample Output 2:20

How would you go about solving this?

agc053_b

Thank you so much TheScrasse!

One of my friend asked me this problem yesterday . Here is a link to my solution to this problem .

Public Test Cases are passing .. And I'm sure it will pass main tests .

PS: Tell me if you want me to explain my approach

Auto comment: topic has been updated by Iwillcomebackstronger (previous revision, new revision, compare).