# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
638744 | jamezzz | Sandcastle 2 (JOI22_ho_t5) | C++17 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sf scanf
#define pf printf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
#define all(x) x.begin(), x.end()
#define lb(x,v) (lower_bound(all(x),v)-x.begin())
#define ub(x,v) (upper_bound(all(x),v)-x.begin())
#define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin());
#define maxn 50005
#define INF 1023456789
int h,w,a[maxn];
stack<int> s;
int main(){
sf("%d%d",&h,&w);
for(int i=0;i<w;++i){
sf("%d",&a[i]);
}
ll ans=0;
for(int i=0;i<w;++i){
while(!s.empty()&&a[s.top()]<a[i])s.pop();
if(s.empty())ans+=i;
else ans+=i-s.top()+1;
s.push(i);
}
while(!s.empty())s.pop();
for(int i=w-1;i>=0;--i){
while(!s.empty()&&a[s.top()]<a[i])s.pop();
if(s.empty())ans+=w-1-i;
else ans+=s.top()-i;
s.push(i);
}
pf("%lld\n",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |