Submission #540985

# Submission time Handle Problem Language Result Execution time Memory
540985 2022-03-22T05:50:50 Z creeped Money (IZhO17_money) C++14
0 / 100
0 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n,a[1000002];
ll cnt;

int main() {

    freopen("money.in", "r", stdin);
    freopen("money.out", "w", stdout);

    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    
    set<ll> st;
    st.insert(100000000);
    int next = 100000000;

    for(ll i=1;i<=n;i++)
    {
        if(i > 1 && a[i] == a[i-1])
            continue;
        auto cur = st.lower_bound(a[i]);
        if(i == 1 || a[i] < a[i-1] || *cur != next)
            cnt ++, next = *st.upper_bound(a[i]);
        st.insert(a[i]);
    }
    cout<<cnt<<endl;

}

Compilation message

money.cpp: In function 'int main()':
money.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("money.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
money.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("money.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -