답안 #467765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467765 2021-08-24T11:51:51 Z Lumos Exam (eJOI20_exam) C++17
12 / 100
141 ms 10808 KB
//amira
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair <ll,ll>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int M = 1e9+7;
const int N = 2e5 + 111;
const ll INF = 1e10 + 1;
const int K = 205;

ll n,a[N],b[N],l[N],r[N],p[N];
map <ll,ll> cnt;

int main() {
	#ifdef MM 
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	stack <ll> st;
	for (int i = n; i >= 1; i--) {
		while (!st.empty() && a[st.top()] <= a[i]) {
			st.pop();
		}
		if (st.empty()) r[i] = n + 1;
		else r[i] = st.top();
		st.push(i);
	}
	while (!st.empty()) st.pop();
	for (int i = 1; i <= n; i++) {
		while (!st.empty() && a[st.top()] <= a[i]) {
			st.pop();
		}
		if (st.empty()) l[i] = 0;
		else l[i] = st.top();
		st.push(i);
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] == b[1]) {
			p[l[i] + 1]++;
			p[r[i]]--;
		}
	}
	for (int i = 1; i <= n; i++) p[i] += p[i - 1];
	ll cnt = 0;
	for (int i = 1; i <= n; i++) if (p[i]) cnt++;
	cout << cnt;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 19 ms 1304 KB Output is correct
3 Correct 79 ms 10316 KB Output is correct
4 Correct 38 ms 4396 KB Output is correct
5 Correct 141 ms 10808 KB Output is correct
6 Correct 41 ms 4336 KB Output is correct
7 Correct 48 ms 4380 KB Output is correct
8 Correct 123 ms 8372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -