Submission #440759

# Submission time Handle Problem Language Result Execution time Memory
440759 2021-07-02T23:24:30 Z MrDeboo Exam (eJOI20_exam) C++17
0 / 100
2 ms 332 KB
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define endl '\n'
using namespace std;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    pair<int,int>pr[n];
    for(int i=0;i<n;i++){
        cin>>pr[i].first;
    }
    for(int i=0;i<n;i++){
        cin>>pr[i].second;
    }
    bool bl[n];
    memset(bl,false,sizeof(bl));
    for(int i=0;i<n;i++){
        int a=0,b=0,z=i,maxi=0,x=0,y=0;
        for(int w=i;w<n&&pr[w].first<=pr[i].first;w++){
            if(pr[w].second==pr[i].first)a++;
            if(bl[w])b++;
            if(a-b>=maxi){x=a;y=b;maxi=a-b;z=w;}
        }
        int f=i;
        a=x;b=y;
        for(int w=(z==i?i:i-1);w>=0&&pr[w].first<=pr[i].first;w--){
            if(a-b>=maxi){maxi=a-b;f=i;}
            if(pr[w].second==pr[i].first)a++;
            if(bl[w])b++;
            if(a-b>=maxi){maxi=a-b;f=w;}
        }
        if(f!=z){
            for(int w=f;w<=z;w++){
                if(pr[w].second==pr[i].first)bl[w]=true;
                else bl[w]=false;
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++)if(bl[i])ans++;
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -