답안 #344388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344388 2021-01-05T15:34:46 Z apostoldaniel854 Money (IZhO17_money) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"


const int MAX_N = 1e6;

int bank[1 + MAX_N];

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

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> bank[i];
    multiset <int> segments;
    int i = 1, seg = 1;
    int biggest = MAX_N * 2;
    while (i <= n) {
        while (i < n && bank[i - 1] <= bank[i] && bank[i] <= biggest) {
            segments.insert (bank[i]);
            i++;
        }
        if (i != n) {
            seg++;
            segments.insert (bank[i]);
            if (segments.upper_bound (bank[i]) != segments.end ())
                biggest = *segments.upper_bound (bank[i]);
            else
                biggest = MAX_N * 2;
        }
        i++;
    }
    cout << seg << "\n";
    return 0;
}
/**
6
3 6 4 5 1 2
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -