답안 #842151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842151 2023-09-02T12:51:46 Z konber Exam (eJOI20_exam) C++14
0 / 100
1 ms 756 KB
#include <iostream>
#include <vector>

using namespace std;

vector<int> A, b;
int N;

int f(vector<int> a, int i){
    if(i==N){
        int ans=0;
        for(int j=0; j < N; j++) ans += a[j]==b[j];
        return ans;
    }

    int j=i, k=i;
    bool changes=true;
    vector<int> a1=a, a2=a;
    while(changes){
        changes = false;
        if(j >= 0 && a[j] <= b[i]){
            a1[j] = b[i];
            changes=true;
            j--;
        }
        if(k <= N-1 && a[k] <= b[i]){
            a2[k] = b[i];
            changes=true;
            k++;
        }
        if(j==0 && k==N-1) break;
    }
    return max(f(a, i+1), max(f(a1, i+1), f(a2, i+1)));
}

int main()
{
    scanf("%d", &N);
    A.resize(N);
    b.resize(N);
    for(int i=0; i < N; i++)
        scanf("%d", &A[i]);
    for(int i=0; i < N; i++)
        scanf("%d", &b[i]);

    if(N <= 10){
        cout << f(A, 0) << endl;
    }
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
exam.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%d", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~
exam.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         scanf("%d", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 436 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 436 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 436 KB Output isn't correct
4 Halted 0 ms 0 KB -