답안 #895811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895811 2023-12-30T21:42:12 Z tvladm2009 Exam (eJOI20_exam) C++17
12 / 100
20 ms 4440 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    vector<int> l(n + 1), r(n + 1);
    vector<int> stk;
    for (int i = 1; i <= n; ++i) {
        while (!stk.empty() && a[i] >= a[stk.back()]) {
            stk.pop_back();
        }
        if (stk.empty()) l[i] = 1;
        else l[i] = stk.back() + 1;
        stk.push_back(i);
    }
    stk.clear();
    for (int i = n; i >= 1; --i) {
        while (!stk.empty() && a[i] >= a[stk.back()]) {
            stk.pop_back();
        }
        if (stk.empty()) r[i] = n;
        else r[i] = stk.back() - 1;
        stk.push_back(i);
    }
    vector<int> mars(n + 10, 0);
    int want = b[1];
    for (int i = 1; i <= n; ++i) {
        if (a[i] == want) {
            ++mars[l[i]];
            --mars[r[i] + 1];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        mars[i] += mars[i - 1];
        if (mars[i] > 0) {
            ++ans;
        }
    }
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 4 ms 1116 KB Output is correct
3 Correct 12 ms 3552 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 20 ms 4440 KB Output is correct
6 Correct 12 ms 2684 KB Output is correct
7 Correct 13 ms 2908 KB Output is correct
8 Correct 18 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 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 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -