✅ 한 것들
⚔️ 백준
6549 히스토그램에서 가장 큰 직사각형
#include"6549.h"
using namespace std;
typedef long long ll;
void B6549::Solution()
{
while (true)
{
int count;
cin >> count;
if (count == 0) break;
ll maxSize = 0;
stack<vector<ll>> st;
while (count--)
{
ll w, h;
cin >> h;
w = 1;
if (!st.empty() && st.top()[0] > h)
{
ll temph;
ll tempw = 0;
while (!st.empty() && st.top()[0] > h)
{
temph = st.top()[0];
tempw += st.top()[1];
maxSize = max(maxSize, temph * tempw);
st.pop();
}
w += tempw;
}
maxSize = max(maxSize, h * w);
st.push({ h,w });
}
ll temph;
ll tempw = 0;
while (!st.empty())
{
temph = st.top()[0];
tempw += st.top()[1];
maxSize = max(maxSize, temph * tempw);
st.pop();
}
cout << maxSize << '\n';
}
}