제출 #37389

#제출 시각아이디문제언어결과실행 시간메모리
37389HardNutMoney (IZhO17_money)C++14
45 / 100
1500 ms5472 KiB
#include <stdio.h>
#include <set>
#include <algorithm>

using namespace std;

const int N = 1e6 + 5;

typedef long long ll;

int n, a[N], ans;
set<int> st;
bool us;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    int i = 1;
    st.insert((int)1e9);
    while (i <= n) {
        int x = *upper_bound(st.begin(), st.end(), a[i]);
        int l = i;
        while (a[i + 1] >= a[i] && a[i + 1] <= x) {
            st.insert(a[i]);
            i++;
        }
        st.insert(a[i]);
        i++;
        ans++;
    }
    printf("%d", ans);
}
/**
6
1 5 2 5 5 6
**/

컴파일 시 표준 에러 (stderr) 메시지

money.cpp: In function 'int main()':
money.cpp:24:13: warning: unused variable 'l' [-Wunused-variable]
         int l = i;
             ^
money.cpp:16:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
money.cpp:18:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...