제출 #533236

#제출 시각아이디문제언어결과실행 시간메모리
533236kebineMoney (IZhO17_money)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h>
using namespace std;

#define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define otsumiko exit(0);
#define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >
#define mikochi priority_queue<long long, vector<long long>, greater<long long> >

int main() {
  nyahalo
  long long n;
  cin >> n;
  long long ans = 1, a, pv, ab;
  set<long long> st;
  for (long long i=1; i<=n; i++) {
    cin >> a;
    if (i > 1) {
      if (a<pv) {
        ans++;
        goto asem; 
      }
      ab = 0;
      if (a == pv) {
        ab = 1;
      }
      auto it = st.lower_bound(a);
      if (it != st.begin()) {
        it--;
        if (*it == pv) {
          ab = 1;
        }
        it++;
      }
      if (it != st.end()) {
        if (*it == pv) {
          ab = 1;
        }
       }
      if (ab == 0) {
        ans++;
      }  
    }
  asem:
    st.insert(a);
    pv = a;
  }
  cout << ans << "\n";
  otsumiko
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...