# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
760042 |
2023-06-17T06:59:48 Z |
ihceker |
Exam (eJOI20_exam) |
C++14 |
|
0 ms |
0 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;
}
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;
}
Compilation message
exam.cpp: In function 'int32_t main()':
exam.cpp:39:7: error: redeclaration of 'long long int ans'
39 | int ans=accumulate(c,c+n,0LL);
| ^~~
exam.cpp:23:12: note: 'long long int ans' previously declared here
23 | int c[n],ans=0;
| ^~~