답안 #38205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38205 2018-01-03T04:09:17 Z antimirage Money (IZhO17_money) C++14
0 / 100
0 ms 5924 KB
#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, inf = 1e9 + 7;

int n, ar[N], cur, ans, l = 1;

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] || (!st.empty() && *st.lower_bound(cur) <= ar[i]) )
        {
            ans++;
            cur = ar[i];

            while ( l < i )
                st.insert(ar[l]), l++;
        }
        i++;
    }
    cout << ans + 1 << endl;
}
/**
6
3 6 4 5 1 2
**/

Compilation message

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]);
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Incorrect 0 ms 5924 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Incorrect 0 ms 5924 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Incorrect 0 ms 5924 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Incorrect 0 ms 5924 KB Output isn't correct
5 Halted 0 ms 0 KB -