답안 #629487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629487 2022-08-14T14:30:18 Z Mer123haba456 Exam (eJOI20_exam) C++14
0 / 100
3 ms 572 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] == b[j])
                sadeg++;
            if(b[i] == a[j]){
                sa = j;
                break;
            }
            if(a[j] >= b[i])
                break;
        }
        for(lli j = i;j>=0;j--){
            if(b[i] == b[j])
                sodeg++;
            if(b[i] == a[j]){
                so = j;
                break;
            }
            if(a[j] >= b[i])
                break;
        }
        
        if(sa != -1){
            lli enb = sadeg;
            for(lli j = i-1;j>=0;j--){
                enb = max(enb, sadeg + dp[j]);
                if(b[j] == b[i])
                    sadeg++;
            }
            enb = max(enb,sadeg);
            dp[sa] = max(dp[sa],enb);
            enf = max(enf,dp[sa]);
        }
        if(so != -1){
            lli enb = sodeg;
            for(lli j = so-1;j>=0;j--){
                enb = max(enb, sodeg + dp[j]);
                if(b[j] == b[i])
                    sodeg++;
            }
            enb = max(enb,sodeg);
            dp[i] = max(dp[i],enb);
            enf = max(enf,dp[i]);
        }
        //cout << so << " " << sa << endl;
    }
    cout << enf << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -