# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38240 | Just_Solve_The_Problem | Money (IZhO17_money) | C++11 | 0 ms | 17644 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pii pair < int, int >
#define fr first
#define sc second
#define pb push_back
#define ok puts("ok");
const int N = (int)1e6 + 7;
pii a[N];
pii a1[N];
stack < int > st;
int ans;
main () {
int n; scanf ("%d", &n);
ans = n;
for (int i = 1; i <= n; i++) {
scanf ("%d", &a[i].fr);
a[i].sc = -i;
a1[i] = a[i];
a1[i].sc = i;
}
sort(a + 1, a + n + 1);
sort(a1 + 1, a1 + n + 1);
for (int i = 1; i <= n; i++) a[i].sc = -a[i].sc;
for (int i = 1; i <= n; i++) {
if (a1[i].sc == a1[i + 1].sc - 1) {
ans--;
continue;
}
int last = a[i].sc;
bool fl = 0;
if (st.size() > 1) {
int cur = st.top();
st.pop();
if (st.top() + 1 == a[i].sc) {
ans--;
st.pop();
} else {
st.push(cur);
}
}
while (!st.empty() && last - 1 == st.top()) {
last = st.top();
ans--;
// ok
fl = 1;
st.pop();
}
if (!fl)
st.push(a[i].sc);
}
cout << 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... |