답안 #465286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465286 2021-08-15T13:45:27 Z CyberCow Exam (eJOI20_exam) C++17
26 / 100
29 ms 1112 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <stack>
using namespace std;
using ll = long long;
const int maxn = 100005;
int a[maxn];
int b[maxn];
bool stug[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, i, j;
    cin >> n;
    for ( i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    if (n <= 10)
    {
        int erk = 1, ma = 0;
        for ( i = 0; i < n; i++)
        {
            erk *= 2;
        }
        for (int mask = 0; mask < erk; mask++)
        {
            int kop = mask;
            for ( i = 0; i < n; i++)
            {
                if ((kop & 1) == 1)
                    stug[i] = 1;
                else
                    stug[i] = 0;
                kop >>= 1;
            }
            int g = 1, ans = 0;
            for ( i = 0; i < n; i++)
            {
                if (stug[i] == 1)
                {
                    ans++;
                    int sm = 0, se = 0, km = 0, ke = 0, maa;
                    j = i, maa = a[i];
                    while (j >= 0)
                    {
                        if (maa == b[i])
                        {
                            sm = 1;
                            break;
                        }
                        if (stug[j] == 1 && b[j] < b[i])
                            km = 1;
                        j--;
                        maa = max(maa, a[j]);
                    }
                    j = i, maa = a[i];
                    while (j < n)
                    {
                        if (maa == b[i])
                        {
                            se = 1;
                            break;
                        }
                        if (stug[j] == 1 && b[j] < b[i])
                            ke = 1;
                        j++;
                        maa = max(maa, a[j]);
                    }
                    if (!((sm && !km) || (se && !ke)))
                    {
                        g = 0;
                        break;
                    }
                }
            }
            if (g)
                ma = max(ma, ans);
        }
        cout << ma;
    }
    else
    {
        for ( i = 0; i < n; i++)
        {
            if (a[i] == b[0])
            {
                j = i - 1;
                while (j >= 0 && a[j] != b[0] && a[j] <= b[0])
                {
                    a[j] = b[0];
                    j--;
                }
                j = i + 1;
                while (j < n && a[j] != b[0] && a[j] <= b[0])
                {
                    a[j] = b[0];
                    j++;
                }
            }
        }
        int ans = 0;
        for ( i = 0; i < n; i++)
        {
            if (a[i] == b[0])
                ans++;
        }
        cout << ans;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 18 ms 972 KB Output is correct
4 Correct 15 ms 1112 KB Output is correct
5 Correct 29 ms 1068 KB Output is correct
6 Correct 15 ms 1100 KB Output is correct
7 Correct 16 ms 1040 KB Output is correct
8 Correct 25 ms 988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -