제출 #94414

#제출 시각아이디문제언어결과실행 시간메모리
94414KastandaMoney (IZhO17_money)C++11
45 / 100
1570 ms58164 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 1000006;
int n, cnt, A[N];
multiset < int > S;
inline void Del(int a)
{
    auto it = S.lower_bound(a);
    if ((*it) == a)
        S.erase(it);
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &A[i]), S.insert(A[i]);
    S.insert(N); // just in case...
    for (int i = n; i;)
    {
        int used = 0;
        int l = i - 1;
        while (l)
        {
            Del(A[l + 1]);
            if (A[l] > A[l + 1])
                break;
            if (A[l] == A[l + 1])
            {
                l --;
                continue;
            }
            auto it = S.upper_bound(A[l]);
            if ((*it) < A[l + 1])
                break;
            if ((*it) == A[l + 1] && used)
                break;
            used = 1;
            l --;
        }
        i = l;
        cnt ++;
    }
    return !printf("%d", cnt);
}

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

money.cpp: In function 'int main()':
money.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
money.cpp:16:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]), S.insert(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...