답안 #760044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760044 2023-06-17T07:00:24 Z ihceker Exam (eJOI20_exam) C++14
39 / 100
80 ms 9256 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];
		memset(c,0,sizeof(c));
		for(int i=0;i<n;i++){
			if(a[i]!=b[i])continue;
			if(!c[i]){
				c[i]=1;
			}
			for(int j=i-1;j>=0;j--){
				if(a[j]>=b[j])break;
				c[j]=1;
			}
			for(int j=i+1;j<n;j++){
				if(a[j]>=b[j])break;
				c[j]=1;
			}
		}
		int ans=accumulate(c,c+n,0LL);
		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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 1140 KB Output is correct
3 Correct 59 ms 7560 KB Output is correct
4 Correct 23 ms 3016 KB Output is correct
5 Correct 80 ms 9256 KB Output is correct
6 Correct 24 ms 2988 KB Output is correct
7 Correct 29 ms 3148 KB Output is correct
8 Correct 76 ms 7476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 25 ms 724 KB Output is correct
5 Correct 9 ms 732 KB Output is correct
6 Correct 11 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 25 ms 724 KB Output is correct
11 Correct 9 ms 732 KB Output is correct
12 Correct 11 ms 724 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -