Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("gogosi.in");
- ofstream g("gogosi.out");
- int cauta(int cas[],int n,int x)
- {
- int m,s,d;
- s=1;
- d=n;
- while(s<=d)
- {
- m=(s+d)/2;
- if(cas[m]==x)
- return m;
- else
- if(x<cas[m])
- s=m+1;
- else
- d=m-1;
- }
- return s;
- }
- int main()
- {
- int n,i,cas[100001],k=1,x,a;
- f>>n>>cas[k];
- for(i=2;i<=n;i++)
- {
- f>>x;
- int a=cauta(cas,k,x);
- if(a<=k)
- cas[a]=x;
- else
- cas[++k]=x;
- }
- g<<k;
- return 0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement