Submission #1049238

# Submission time Handle Problem Language Result Execution time Memory
1049238 2024-08-08T15:21:46 Z mar Exam (eJOI20_exam) C++14
0 / 100
13 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100008;
 
ll dp[maxn];
 
int main() {
    int n; cin>>n;
    int ans=0;
	vector<int> a, b;
	bool flag = true;
	int inp;
	for(int i=0;i<n;i++) {
		cin>>inp; 
		a.push_back(inp);
		if(i>0 && inp <= a[i-1]) flag=false;
	}
	
	for(int i=0;i<n;i++){
	    cin>>inp;
	    b.push_back(inp);
	} 
	
	if(!flag) {
	    vector<int> v;
	    map<int, int> idx;
    	for(int i=0; i<n; i++) idx[a[i]] = i;
    	for(int i=0; i<n; i++) {
    		if(idx.count(b[i]) && i <= idx[b[i]]) v.push_back(b[i]);
    	}
    	
    	ll mx = 0;
    	for (int i=0; i<n; i++) {
    		for(int j=0; j<i; j++) {
    			if(v[i] >= v[j]) { 
    				dp[i] = max(dp[i], dp[j]+1);
    			}
    		}
    	}
    	for(int i=0; i<n; i++) {
    		mx = max(mx,dp[i]);
    	}
    	cout<<mx+1<<endl;
		return 0;
	}
	
	for(int i=0; i<n; i++) {
		if(a[i] != inp)continue;
		int tmp = i-1;
		while(tmp >= 0 && a[tmp] <= inp) {
			ans++;
			tmp--;
		}
		while(i < n && a[i] <= inp) {
			ans++;
			i++;
		}
	}
	cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -