Submission #833514

# Submission time Handle Problem Language Result Execution time Memory
833514 2023-08-22T06:23:57 Z vjudge1 Exam (eJOI20_exam) C++17
0 / 100
4 ms 1360 KB
/******************************************************************************

Welcome to GDB Online.
  GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
  C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
  Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>


using namespace std;


const int N = 1e5 + 5;

map<int, int> letak;

int st[N*2 + 5];

void modify(int pos, int val){
    for(pos += N, st[pos] = val; pos > 1; pos >>= 1){
        st[pos >> 1] = max(st[pos], st[pos^1]);
    }
}

int query(int l, int r){
    int mx = 0;
    for(l += N, r += N; l < r; l >>= 1, r >>= 1){
        if(l&1){
            mx = max(mx, st[l++]);
        }
        if(r & 1){
            mx = max(mx, st[--r]);
        }
    }
    return mx;
}


void solve(){
    int n;
    cin >> n;
    int t[n + 1], h[n + 1];
    for(int i = n; i >= 1; i--){
        cin >> h[i];
    }
    for(int i = n; i >= 1; i--){
        cin >> t[i];
    }
    memset(st, 0, sizeof(st));
    set<int> sets;
    for(int i = 1; i <= n; i++){
        while(!sets.empty() && *sets.begin() < h[i]){
            sets.erase(sets.begin());
        }
        int mx = query(0, i);
        modify(i, mx);
        sets.insert(h[i]);
        letak[h[i]] = i;
        if(sets.find(t[i]) != sets.end()){
            modify(letak[t[i]], st[N + letak[t[i]]] + 1);
        }
    }
    cout << query(0,  n + 1) << endl;
    
    
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while(t--){
        solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -