# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
512027 | kartel | Po (COCI21_po) | C++14 | 44 ms | 3476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define sz(x) (int)x.size()
using namespace std;
const int N = 1e5 + 500;
int r[N];
bool mk[N];
int main() {
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector <int> b = {a[0]};
for (int i = 1; i < n; i++) {
if (a[i] != b.back()) {
b.pb(a[i]);
}
}
a = b;
vector <pair <int, int> > st;
st.pb({-1, sz(a)});
for (int i = sz(a) - 1; i >= 0; i--) {
while (sz(st) && st.back().F > a[i]) {
st.pop_back();
}
r[i] = st.back().S;
st.pb({a[i], i});
}
n = sz(a);
int ans = 0;
for (int i = 0; i < n; i++) {
if (mk[i]) {
continue;
}
ans += (a[i] > 0);
mk[r[i] - 1] = 1;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |