Alex_tz307

SCLM upper_bound

Sep 12th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main () {
  6.     ifstream fin ("sclm2.in");
  7.     ofstream fout ("sclm2.out");
  8.     vector < int > deck;
  9.     int n, x;
  10.     for(fin >> n; n; n--) {
  11.         fin >> x;
  12.         auto it = upper_bound(deck.begin(), deck.end(), x);
  13.         if(it == deck.end())
  14.             deck.emplace_back(x);
  15.         else
  16.             *it = x;
  17.     }
  18.     fout << deck.size();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment