Submission #760035

# Submission time Handle Problem Language Result Execution time Memory
760035 2023-06-17T06:56:44 Z ihceker Exam (eJOI20_exam) C++14
27 / 100
32 ms 732 KB
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main(){
	int n;
	cin>>n;
	int a[n],b[n];
	set<int>s;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.insert(a[i]);
	}
	for(int i=0;i<n;i++)cin>>b[i];
	if(*max_element(b,b+n)==*min_element(b,b+n)){
		int c[n],ans=0;
		memset(c,0,sizeof(c));
		for(int i=0;i<n;i++){
			if(a[i]>b[i])continue;
			if(!c[i]){
				c[i]=1;
				ans++;
			}
			for(int j=i-1;j>=0;j--){
				if(a[j]>=b[j])break;
				if(!c[j]){
					c[j]=1;
					ans++;
				}
			}
			for(int j=i+1;j<n;j++){
				if(a[j]>=b[j])break;
				if(!c[j]){
					c[j]=1;
					ans++;
				}
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	vector<pair<int,int>>v;
	for(int i=0;i<n;i++){
		if(a[i]>b[i] || !s.count(b[i]))continue;
		v.pb({b[i],i});
	}
	sort(all(v));
	int dp[v.size()],ans=0;
	for(int i=0;i<(int)v.size();i++){
		int mx=0;
		for(int j=0;j<i;j++){
			if(v[i].ss>v[j].ss)mx=max(mx,dp[j]);
		}
		dp[i]=mx+1;
		ans=max(ans,mx+1);
	}
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 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 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 32 ms 724 KB Output is correct
5 Correct 10 ms 732 KB Output is correct
6 Correct 13 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 32 ms 724 KB Output is correct
11 Correct 10 ms 732 KB Output is correct
12 Correct 13 ms 724 KB Output is correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -