답안 #169682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169682 2019-12-22T08:56:02 Z stefdasca Money (IZhO17_money) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;

int n, ans = 1, v[1000002];
multiset<int> s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    s.insert(v[1]);
    int i = 2;
    while(i <= n && v[i] >= v[i-1])
        s.insert(v[i]), ++i;
    for(; i <= n; )
    {
        ++ans;
        multiset<int> ::iterator it = s.lower_bound(v[i]);
        multiset<int> ::iterator it2 = it;
        if(it == s.end())
        {
            int j = i+1;
            s.insert(v[i]);
            while(j <= n && v[j] >= v[j-1])
                s.insert(v[j]), ++j;
            i = j;
        }
        else
        {
            if(it == s.begin() && v[i] < *it)
            {
                int j = i+1;
                int val = *it;
                s.insert(v[i]);
                while(j <= n && v[j] >= v[j-1] && v[j] <= val)
                    s.insert(v[j]), ++j;
                i = j;
            }
            else
            {
                if(*it == v[i])
                {
                    ++it2;
                    if(it2 == s.end())
                    {
                        int j = i+1;
                        s.insert(v[i]);
                        while(j <= n && v[j] >= v[j-1])
                            s.insert(v[j]), ++j;
                        i = j;
                    }
                    else
                    {
                        int j = i+1;
                        int val = *it2;
                        s.insert(v[i]);
                        while(j <= n && v[j] >= v[j-1] && v[j] <= val)
                            s.insert(v[j]), ++j;
                        i = j;
                    }
                }
                else
                {
                    int j = i+1;
                    int val = *it;
                    s.insert(v[i]);
                    while(j <= n && v[j] >= v[j-1] && v[j] <= val)
                        s.insert(v[j]), ++j;
                    i = j;
                }
            }
        }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -