답안 #588478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
588478 2022-07-03T11:00:34 Z berr Exam (eJOI20_exam) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
 
    int n; cin>>n;
    if(n>10) cout<<"bruuuuuuuuuuuuh";
    else
    {
        vector<int> a(n), b(n), c(n);
 
 
        for(int i=0; i<n; i++) cin>>a[i], c[i]=a[i];
        for(int i=0; i<n; i++) cin>>b[i];
 
 
        int ans=0;
        for(int i=1; i<1<<n; i++)
        {
 
            a=c;
            int flag=1, p=0;;
            for(int l=0; l<n&&flag; l++)
            {
            
                if(a[l]>b[l]&&(i&(1<<l))) flag=0;
 
                else if(i&(1<<l)){   
                    p++;
                    int j=l;
                    if(a[l]==b[l]) continue;
                    int val=a[l];
                    if(j>=0){
                    while(val<b[l]) 
                    {
                        if(i&(1<<j)&&max(val, b[j])!=b[l]) break;
                        val=max(val, a[j]);
 
                        if(j==0||val==b[l]) break;
                        else j--;
 
                    }}
 
                    if(val!=b[l])
                    {   
                        j=l+1;
                        val=a[l];
                        while(val<b[l])
                        {
 
                            val=max(val, a[j]);
                            if(j==n-1||val==b[l]) break;
                            else j++;
 
                        }
 
                    
                        if(val!=b[l]) flag=0;
                        else
                        {
                            for(int k=l; k<=j; k++)
                                a[k]=val;
                        }
 
                    }
                    else a[l]=b[l]; 
                }
            }
 
            if(flag) ans=max(ans, p);
 
 
 
        }
 
        cout<<ans<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 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 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 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 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -