Submission #460773

# Submission time Handle Problem Language Result Execution time Memory
460773 2021-08-09T09:31:21 Z Tenis0206 Exam (eJOI20_exam) C++11
12 / 100
39 ms 4288 KB
#include <bits/stdc++.h>

using namespace std;
int n;
int a[100005],b[100005],aux[100005],l[100005],r[100005],fr[100005];
bool subtask2()
{
    for(int i=2; i<=n; i++)
    {
        if(b[i]!=b[i-1])
        {
            return false;
        }
    }
    return true;
}
bool subtask4()
{
    for(int i=1; i<=n; i++)
    {
        aux[i] = a[i];
    }
    sort(aux+1,aux+n+1);
    for(int i=2; i<=n; i++)
    {
        if(aux[i]==aux[i-1])
        {
            return false;
        }
    }
    return true;
}
int solve_subtask2()
{
    stack<int> st;
    for(int i=1; i<=n; i++)
    {
        while(!st.empty() && a[i]>a[st.top()])
        {
            st.pop();
        }
        if(st.empty())
        {
            l[i] = 0;
        }
        else
        {
            l[i] = st.top();
        }
        st.push(i);
    }
    while(!st.empty())
    {
        st.pop();
    }
    for(int i=n; i>=1; i--)
    {
        while(!st.empty() && a[i]>a[st.top()])
        {
            st.pop();
        }
        if(st.empty())
        {
            r[i] = n+1;
        }
        else
        {
            r[i] = st.top();
        }
        st.push(i);
        if(a[i]==b[1])
        {
            ++fr[l[i]+1];
            --fr[r[i]];
        }
    }
    int rez = 0;
    for(int i=1; i<=n; i++)
    {
        fr[i]+=fr[i-1];
        if(fr[i])
        {
            ++rez;
        }
    }
    return rez;
}
int solve_subtask4()
{
    return 0;
}
int solve_general()
{
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<=n; i++)
    {
        cin>>b[i];
    }
    if(subtask2())
    {
        cout<<solve_subtask2()<<'\n';
        return 0;
    }
    if(subtask4())
    {
        cout<<solve_subtask4()<<'\n';
        return 0;
    }
    cout<<solve_general()<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 1104 KB Output is correct
3 Correct 20 ms 3512 KB Output is correct
4 Correct 17 ms 2984 KB Output is correct
5 Correct 39 ms 4288 KB Output is correct
6 Correct 20 ms 2732 KB Output is correct
7 Correct 21 ms 2828 KB Output is correct
8 Correct 30 ms 4176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -