Submission #833262

# Submission time Handle Problem Language Result Execution time Memory
833262 2023-08-22T03:49:45 Z vjudge1 Exam (eJOI20_exam) C++17
0 / 100
3 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
typedef long long ll;
const ll MAXN = 1e5 + 5;
const ll INF = 1e9;
#define endl '\n'
#define pll pair <ll, ll>
#define fi first
#define se second

ll n;
ll a [MAXN], b [MAXN];
ll par [MAXN];
ll dp [MAXN];

ll bpk(ll x){
    if(par[x] == x) return x;
    return par[x] = bpk(par[x]);
}

int main(){
    cin >> n;
    for(ll i = 1; i <= n; i++){
        cin >> a[i];
    }
    ll cnt = 0;
    ll cnt2 = 0;
    for(ll i = 1; i <= n; i++){
        cin >> b[i];
        if(b[1] == b[i]) cnt++;
        if(b[i-1] < b[i]) cnt2++;
    }
    if(cnt == n){
        for(ll i = 1; i <= n; i++){
            par[i] = i;
        }
        a[0] = INF * 2;
        for(ll i = 1; i <= n; i++){
            if(a[i] <= b[1]){
                if(a[i-1] <= b[1]){
                    if(a[i] >= a[i-1]){
                        par[bpk(i-1)] = bpk(i);
                    }
                    else{
                        par[bpk(i)] = bpk(i-1);
                    }
                }
            }
        }
        ll ans = 0;
        for(ll i = 1; i <= n; i++){
            if(a[bpk(i)] == b[1]){
                ans++;
            }
        }
        cout << ans << endl;
        exit(0);
    }
    // if(cnt2 == n){
    //     for(ll i = 1; i <= n; i++){
    //         for(ll j = i; j <= n; j++){
    //             if(a[j] > b[i]){
    //                 par[i] = -1;
    //             }
    //             if(a[j] == b[i]){
    //                 par[i] = j;
    //             }
    //         }
    //     }
    //     for(ll i = n; i >= 1; i--){
    //         dp[i] = dp[i+1];
    //         ll cnt = par[i] - i;
    //         for(ll j = i+1; j <= par[i]-1; j++){
    //             if(par[j] < par[i]) cnt--;
    //         }
    //     }
    // }
}
# 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 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 3 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 -