Submission #588418

# Submission time Handle Problem Language Result Execution time Memory
588418 2022-07-03T09:14:26 Z dozer Exam (eJOI20_exam) C++14
12 / 100
24 ms 5476 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define N 500005
#define pii pair<int, int>
#define st first
#define nd second
#define modulo 1000000007
#define LOGN 18
#define int long long


int nxt[N], prv[N], a[N], b[N];


int32_t main()
{
	fastio();


	int n;
	cin>>n;
	for (int i = 1; i <= n; i++)
		cin>>a[i];
	for (int i = 1; i <= n; i++)
		cin>>b[i];
	prv[1] = 0;
	a[0] = modulo;
	nxt[n] = n + 1;
	a[n + 1] = modulo;
	for (int i = 2; i <= n; i++)
	{
		prv[i] = i - 1;
		while(a[prv[i]] < a[i]) prv[i] = prv[prv[i]];
	}
	for (int i = n - 1; i >= 1; i--)
	{
		nxt[i] = i + 1;
		while (a[nxt[i]] < a[i]) nxt[i] = nxt[nxt[i]];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] != b[i]) continue;
		int l = prv[i], r = nxt[i];
		if (a[nxt[i]] == a[i]) r = i + 1;
		ans += r - l - 1;
		//cout<<l<<sp<<r<<endl;
	}
	cout<<ans<<endl;

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 6 ms 1280 KB Output is correct
3 Correct 13 ms 4108 KB Output is correct
4 Correct 10 ms 3812 KB Output is correct
5 Correct 24 ms 5476 KB Output is correct
6 Correct 11 ms 3812 KB Output is correct
7 Correct 14 ms 3984 KB Output is correct
8 Correct 22 ms 5352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -