Submission #545276

#TimeUsernameProblemLanguageResultExecution timeMemory
545276Ai7081Money (IZhO17_money)C++17
100 / 100
1079 ms47328 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 1000005;
const int inf = 1e9;

int n, a, out=1, now, nxt=inf;
multiset<int> s;

int main() {
    scanf(" %d", &n);
    while (n--) {
        scanf(" %d", &a);
        auto it = s.insert(a);
        if (a < now || a > nxt) {
            out++;
            while (it != s.end() && *it == a) it++;
            nxt = (it == s.end()) ? inf : *it;
        }
        now = a;
    }
    printf("%d", out);
    return 0;
}

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %d", &n);
      |     ~~~~~^~~~~~~~~~~
money.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf(" %d", &a);
      |         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...