Submission #833175

# Submission time Handle Problem Language Result Execution time Memory
833175 2023-08-22T02:48:33 Z vjudge1 Exam (eJOI20_exam) C++17
0 / 100
3 ms 340 KB
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
using namespace std;
int n, h[100010], t[100010], ans;
bool vis[100010];
vector<int> tmp;

void sub2(){
	for(auto i : tmp){
		vis[i]=1; 
		ans++;
		int l=i, r=i;
		while(l-1>=1 && !vis[l-1]){
			l--;
			vis[l]=1;
			if(h[l]>=h[i]) break;
			ans++;
		}
		while(r+1<=n && !vis[r+1]){
			r++;
			vis[r]=1;
			if(h[r]>=h[i]) break;
			ans++;
		}
	}	
}

void sub3(){
	set<int> tmp;
	for(int i=n; i>=1; i--){
		tmp.insert(h[i]);
		if(tmp.find(t[i])!=tmp.end()){
			ans++;
		}
	}
}

int main(){
	bool s2=1, s3=1;
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> h[i];
		if(i>1 && h[i]<=h[i-1])s3=0;
	}
	for(int i=1; i<=n; i++){
		cin >> t[i];
		if(t[i]==h[i]){
			tmp.pb(i);
		}
		else s2=0;	
	}
	if(s2){
		sub2();
	}
	else if(s3){
		sub3();
	}
	cout << ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -