Advertisement
Guest User

Untitled

a guest
Jan 16th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1.  
  2.  
  3. #include <fstream>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. ifstream ifs("input.txt");
  9. ofstream ofs("output.txt");
  10. int a[10000000];
  11. int t[10000000];
  12.  
  13. int f(int n){
  14.     int max=0;
  15.     t[0]=1;
  16.     for(int i=1;i<n;i++){
  17.         int m=0;
  18.         for(int j=0;j<i;j++){
  19.             if(a[i]>a[j]&&t[j]>m){
  20.                 t[i]=t[j]+1;
  21.                 m=t[j];
  22.                 };
  23.             if(!t[i])t[i]++;
  24.             if(t[i]>max)max=t[i];
  25.             };
  26.     };
  27.     return max;
  28. };
  29.  
  30.  
  31. int main()
  32. {
  33.     int n,k,max,h=0;
  34.     ifs>>n>>k;
  35.     int t;
  36.     for(int i=0;i<n;i++){
  37.         ifs>>t;
  38.         for(int j=0;j<k;j++)a[(n*(j+1)-i-1)*(j%2)+(n*j+i)*((j+1)%2)]=t;
  39.         };
  40.     ofs<<f(k*n);
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement