(I2
I116
I5
(dp0
Vmaxarrea.%l
p1
(Vmaxarea.cpp
p2
S'#include <bits/stdc++.h>\n//#define DEBUG\n\nusing namespace std;\n\nconst int MAX_N = 1e6 + 42;\n\nint height[MAX_N];\nint len;\n\nint main() {\n\tscanf("%i", &len);\n\tfor (int i = 0;i < len;i++) {\n\t\tscanf("%i", &height[i]);\n\t}\n\n\tstack<int> h;\n\tstack<int> x;\n\n\tint maxArea = -1;\n\tfor (int i = 0;i < len;i++) {\n\t\tint curX = i;\n\t\twhile ((not h.empty()) && (h.top() > height[i])) {\n\t\t\tint curArea = h.top() * (i - x.top());\n\t\t\tcurX = x.top();\n#ifdef DEBUG\n\t\t\tprintf("(%i %i %i %i)\\n", i, h.top(), x.top(), curArea);\n#endif\n\t\t\tmaxArea = max(curArea, maxArea);\n\t\t\th.pop();\n\t\t\tx.pop();\n\t\t}\n#ifdef DEBUG\n\t\tprintf("\\n");\n#endif\n\n\t\tif ((h.empty()) || (height[i] > h.top())) {\n\t\t\th.push(height[i]);\n\t\t\tx.push(curX);\n\t\t}\n\t}\n\n\twhile (not h.empty()) {\n\t\tint curArea = h.top() * (len - x.top());\n\t\tmaxArea = max(maxArea, curArea);\n\n\t\th.pop();\n\t\tx.pop();\n\t}\n\n\tprintf("%i\\n", maxArea);\n}\n'
p3
tp4
stp5
.