답안 #425593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
425593 2021-06-13T08:15:47 Z MilosMilutinovic Exam (eJOI20_exam) C++14
12 / 100
1000 ms 3020 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long unsigned long ull;
typedef double long ld;

int n, a[100050], b[100050];

void solve2() {
  for (int i = 1; i <= n; i++) {
    if (a[i] == b[i]) {
      for (int j = i + 1; j <= n; j++) {
        if (a[j] >= a[i]) {
          break;
        }
        a[j] = a[i];
      }
      for (int j = i - 1; j >= 1; j--) {
        if (a[j] >= a[i]) {
          break;
        }
        a[j] = a[i];
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (a[i] == b[i] ? 1 : 0);
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(!cin.tie(0));

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  if (*max_element(b + 1, b + n + 1) == *min_element(b + 1, b + n + 1)) {
    solve2();
    return 0;
  }
  if (n <= 10) {
    auto c = a;
    int ans = 0;
    function<void(int*)> Brut = [&](int* niz) {
      int cnt = 0;
      for (int i = 1; i <= n; i++) {
        cnt += niz[i] == b[i];
      }
      ans = max(ans, cnt);
      for (int i = 1; i <= n; i++) {
        int mx = 0;
        int novi[n + 1];
        for (int j = 1; j <= n; j++) {
          novi[j] = niz[j];
        }
        for (int j = i; j <= n; j++) {
          mx = max(mx, niz[j]);
          bool ok = false;
          for (int l = i; l <= j; l++) {
            if (niz[l] != mx) {
              ok = true;
            }
            novi[l] = mx;
          }
          if (ok) {
            Brut(novi);
          }
        }
      }
    };
    Brut(c);
    cout << ans << '\n';
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 44 ms 304 KB Output is correct
4 Correct 41 ms 204 KB Output is correct
5 Execution timed out 1083 ms 204 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 460 KB Output is correct
3 Correct 24 ms 2040 KB Output is correct
4 Correct 20 ms 1476 KB Output is correct
5 Correct 30 ms 3012 KB Output is correct
6 Correct 21 ms 1356 KB Output is correct
7 Correct 17 ms 1632 KB Output is correct
8 Correct 35 ms 3020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 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 1 ms 204 KB Output is correct
3 Correct 44 ms 304 KB Output is correct
4 Correct 41 ms 204 KB Output is correct
5 Execution timed out 1083 ms 204 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 44 ms 304 KB Output is correct
4 Correct 41 ms 204 KB Output is correct
5 Execution timed out 1083 ms 204 KB Time limit exceeded
6 Halted 0 ms 0 KB -