답안 #644070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644070 2022-09-23T17:47:10 Z Alexandruabcde Money (IZhO17_money) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

constexpr int NMAX = 1e6 + 5;

int N;
int A[NMAX];

set <int> S;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;

    for (int i = 1; i <= N; ++ i )
        cin >> A[i];

    int ans = 0;

    for (int i = 1; i <= N; ++ i ) {
        ++ ans;
        int j = i;

        if (S.empty()) {
            for (; j <= N && A[j+1] >= A[j]; ++ j );

            for (int k = i; k <= j; ++ k )
                S.insert(A[k]);
            i = j;

            continue;
        }

        auto it = S.upper_bound(A[i]);

        if (it == S.end()) {
            for (; j <= N && A[j+1] >= A[j]; ++ j );

            for (int k = i; k <= j; ++ k )
                S.insert(A[k]);
            i = j;

            continue;
        }

        for (; j <= N && A[j+1] >= A[j] && A[j+1] < *it; ++ j );

        for (int k = i; k <= j; ++ k )
            S.insert(A[k]);
        i = j;
    }

    cout << ans << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -