Submission #38215

#TimeUsernameProblemLanguageResultExecution timeMemory
38215antimirageMoney (IZhO17_money)C++11
45 / 100
1500 ms52784 KiB
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 1e6 + 5;

int n, ar[N], cur, ans, l = 1, pos = 1e9 + 7;

set <int> st;

main ()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d", &ar[i]);

    cur = ar[1];

    int i = 1;

    while (i <= n)
    {
        if ( ar[i] < ar[i - 1] || pos < ar[i] )
        {
            ans++;
            cur = ar[i];

            while ( l < i )
                st.insert(ar[l]), l++;

            if (st.lower_bound(cur + 1) == st.end()) pos = 1e9 + 7;

            else pos = *st.lower_bound( cur + 1 );
        }
        i++;
    }
    cout << ans + 1 << endl;
}
/**
7
1 2 1 2 3 4 5
**/

Compilation message (stderr)

money.cpp:31:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main ()
       ^
money.cpp: In function 'int main()':
money.cpp:35:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &ar[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...