# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833483 |
2023-08-22T06:07:20 Z |
vjudge1 |
Exam (eJOI20_exam) |
C++17 |
|
58 ms |
2404 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;
const ll INF=1e10;
ll n, h[100010], t[100010], dp[100010], ans;
bool vis[100010], ok[100010];
vector<ll> tmp;
void brute(){
for(ll mask=0; mask<=1<<10-1; mask++){
}
}
void sub2(){
for(auto i : tmp){
vis[i]=1;
ans++;
ll 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<ll> tmp;
for(ll i=n; i>=1; i--){
tmp.insert(h[i]);
if(tmp.find(t[i])!=tmp.end()){
ok[i]=1;
}
}
vector<ll> lis;
for(int i=1; i<=n; i++){
if(ok[i]) lis.pb(i);
}
int sz=lis.size();
for(int i=0; i<sz; i++){
dp[i]=INF;
}
for(int i=0; i<sz; i++) {
int idx=(lower_bound(dp, dp+sz, lis[i])-dp);
dp[idx]=lis[i];
}
for(int i=0; i<sz; i++) {
if (dp[i]<INF) ans=i+1;
}
}
int main(){
bool s2=1, s3=1;
cin >> n;
for(ll i=1; i<=n; i++){
cin >> h[i];
if(i>1 && h[i-1]>=h[i]) s3=0;
}
for(ll i=1; i<=n; i++){
cin >> t[i];
if(t[i]==h[i]){
tmp.pb(i);
}
if(i>1 && t[i]!=t[i-1]) s2=0;
}
if(s2){
sub2();
}
else if(s3){
sub3();
}
else{
brute();
}
cout << ans << endl;
return 0;
}
Compilation message
exam.cpp: In function 'void brute()':
exam.cpp:14:28: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
14 | for(ll mask=0; mask<=1<<10-1; mask++){
| ~~^~
# |
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 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
12 ms |
596 KB |
Output is correct |
3 |
Correct |
36 ms |
1720 KB |
Output is correct |
4 |
Correct |
23 ms |
1952 KB |
Output is correct |
5 |
Correct |
58 ms |
1924 KB |
Output is correct |
6 |
Correct |
23 ms |
2404 KB |
Output is correct |
7 |
Correct |
32 ms |
1968 KB |
Output is correct |
8 |
Correct |
58 ms |
1832 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 |
Incorrect |
4 ms |
340 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 |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |