답안 #629496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629496 2022-08-14T14:47:29 Z Mer123haba456 Exam (eJOI20_exam) C++14
0 / 100
2 ms 596 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
#define N lli(2e6)
#define MOD lli(1e9 + 7)
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0);
#define heps(v) v.begin(),v.end()
typedef vector<lli> vlli;
typedef pair<lli,lli> plli;
typedef pair<lli,plli> pplli;
typedef vector<plli> vplli;
typedef vector<pplli> vpplli;
typedef map<lli,lli> mlli;

lli t,n,m,k;

string str;

vlli a,b;

lli dp[N];

int main(){
    fast_io
    cin >>n;
    for(lli i = 0;i<n;i++){
        cin >> k;
        a.push_back(k);
    }
    for(lli i = 0;i<n;i++){
        cin >> k;
        b.push_back(k);
    }
    lli enf = 0;
    for(lli i = 0;i<n;i++){
        lli sa = -1,so = -1;
        lli sadeg = 0, sodeg = 0;
        
        for(lli j = i;j<n;j++){
            if(b[i] == a[j]){
                sa = j;
                break;
            }
            if(a[j] >= b[i])
                break;
        }
        for(lli j = i;j>=0;j--){
            if(b[i] == a[j]){
                so = j;
                break;
            }
            if(a[j] >= b[i])
                break;
        }
        lli saat = -1;
        if(sa != -1){
            for(lli j = i+1;j<=sa;j++)
                if(b[j] == b[i])
                    sadeg++;
            lli enb = sadeg;
            for(lli j = i;j>=0;j--){
                bool eks = 0;
                if(j == i && a[i] == b[i])
                    eks = 1;
                enb = max(enb, sadeg + dp[j] - eks);
                if(b[j] == b[i])
                    sadeg++;
            }
            enb = max(enb,sadeg);
            saat = enb;
            
        }
        if(so != -1){
            for(lli j = i;j>=so+1;j--)
                if(b[j] == b[i])
                    sodeg++;
            lli enb = sodeg;
            for(lli j = so;j>=0;j--){
                bool eks = 0;
                if(j == so && a[so] == b[so])
                    eks = 1;
                enb = max(enb, sodeg + dp[j] - eks);
                if(b[j] == b[i])
                    sodeg++;
            }
            enb = max(enb,sodeg);
            dp[i] = max(dp[i],enb);
            enf = max(enf,dp[i]);
        }
        if(sa != -1){
            dp[sa] = max(dp[sa],saat);
            enf = max(enf,dp[sa]);
        }
        //cout << so << " " << sa << " " << enf << endl;
    }
    cout << enf << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 332 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 332 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 332 KB Output isn't correct
7 Halted 0 ms 0 KB -