Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int N,a,b,c,d,wynik;
- vector <pair <int, int > >tab;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cin>>N;
- tab.push_back(make_pair(0,0));
- cin>>a;
- tab.push_back(make_pair(a,0));
- tab.push_back(make_pair(1000001,0));
- for(int i=1;i<N;i++)
- {
- cin>>a;
- b=0;
- d=tab.size();
- while (b < d) {
- c = (d + b) / 2;
- if (tab[c].first >= a) {
- d = c;
- }
- else {
- b = c+1;
- }
- }
- tab.insert(tab.begin()+c,make_pair(a,max(tab[c].second,tab[c].second)+1));
- wynik=max(wynik,tab[c+1].second);
- }
- for(int i=0;i<tab.size();i++)
- {
- cout<<tab[i].first<<" ";
- }
- cout<<endl;
- for(int i=0;i<tab.size();i++)
- {
- cout<<tab[i].second<<" ";
- }
- cout<<endl;
- cout<<wynik;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement