{"problem":{"name":"B. Okabe and Banana Trees","description":{"content":"Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (_x_, _y_) in the 2D plane such that _x_ and _y_ are","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF821B"},"statements":[{"statement_type":"Markdown","content":"Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.\n\nConsider the point (_x_, _y_) in the 2D plane such that _x_ and _y_ are integers and 0 ≤ _x_, _y_. There is a tree in such a point, and it has _x_ + _y_ bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation . Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.\n\nHelp Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.\n\nOkabe is sure that the answer does not exceed 1018. You can trust him.\n\n## Input\n\nThe first line of input contains two space-separated integers _m_ and _b_ (1 ≤ _m_ ≤ 1000, 1 ≤ _b_ ≤ 10000).\n\n## Output\n\nPrint the maximum number of bananas Okabe can get from the trees he cuts.\n\n[samples]\n\n## Note\n\n<center>![image](https://espresso.codeforces.com/4332070c474c92227eb148520525b2a2a305d8c7.png)</center>The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Okabe 需要一些香蕉用于他的一个实验，原因很奇怪。因此，他决定去森林里砍香蕉树。\n\n考虑二维平面上的点 #cf_span[(x, y)]，其中 #cf_span[x] 和 #cf_span[y] 是整数，且 #cf_span[0 ≤ x, y]。在这样的点上有一棵树，树上有 #cf_span[x + y] 根香蕉。其他点上没有树，也没有香蕉。现在，Okabe 画出一条方程为 的直线。Okabe 可以选择一个边与坐标轴平行的矩形，该矩形包含所有位于该直线之上或之下的点，并砍掉该矩形内部或边界上的所有树，取走它们的香蕉。Okabe 的矩形可以是退化的；也就是说，它可以是一条线段，甚至是一个点。\n\n请帮助 Okabe，找出他明智选择矩形时能获得的最大香蕉数量。\n\nOkabe 确信答案不超过 #cf_span[1018]。你可以相信他。\n\n输入的第一行包含两个用空格分隔的整数 #cf_span[m] 和 #cf_span[b]（#cf_span[1 ≤ m ≤ 1000]，#cf_span[1 ≤ b ≤ 10000]）。\n\n请输出 Okabe 从他砍的树上能得到的最大香蕉数量。\n\n上图对应于样例测试 1。最优矩形用红色标出，包含 #cf_span[30] 根香蕉。\n\n## Input\n\n输入的第一行包含两个用空格分隔的整数 #cf_span[m] 和 #cf_span[b]（#cf_span[1 ≤ m ≤ 1000]，#cf_span[1 ≤ b ≤ 10000]）。\n\n## Output\n\n请输出 Okabe 从他砍的树上能得到的最大香蕉数量。\n\n[samples]\n\n## Note\n\n上图对应于样例测试 1。最优矩形用红色标出，包含 #cf_span[30] 根香蕉。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ m, b \\in \\mathbb{Z}^+ $ be given parameters.  \nFor any point $ (x, y) \\in \\mathbb{Z}_{\\geq 0}^2 $, the number of bananas at $ (x, y) $ is $ x + y $.  \nLet $ L $ be the line defined by $ y = -m x + b $.  \n\nLet $ R \\subseteq \\mathbb{Z}_{\\geq 0}^2 $ be a rectangle with axis-aligned sides, such that all points $ (x, y) \\in R $ satisfy $ y \\leq -m x + b $.  \n\n**Constraints**  \n1. $ 1 \\leq m \\leq 1000 $  \n2. $ 1 \\leq b \\leq 10000 $  \n3. $ x, y \\in \\mathbb{Z}_{\\geq 0} $  \n4. For all $ (x, y) \\in R $: $ y \\leq -m x + b $  \n\n**Objective**  \nMaximize the total number of bananas:  \n$$\n\\max_{R} \\sum_{(x,y) \\in R} (x + y)\n$$  \nwhere $ R $ ranges over all axis-aligned rectangles contained in $ \\{ (x, y) \\in \\mathbb{Z}_{\\geq 0}^2 \\mid y \\leq -m x + b \\} $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF821B","tags":["brute force","math"],"sample_group":[["1 5","30"],["2 3","25"]],"created_at":"2026-03-03 11:00:39"}}