rotti321

3minime

Aug 17th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     long long n,y,i,z,x=0,MIN1,MIN2,MIN3;
  8.     cin>> n ;
  9.     cin>> x >> y;
  10.     MIN1=min(x,y);
  11.     MIN2=max(x,y);
  12.     for(i=1;i<=n-2;i++){
  13.         cin>>x;
  14.         if(x<=MIN1){
  15.             MIN3=MIN2;
  16.             MIN2=MIN1;
  17.             MIN1=x;
  18.         }
  19.         else{
  20.             if(x<=MIN2 && x>MIN1){
  21.                 MIN3=MIN2;
  22.                 MIN2=x;
  23.             }
  24.             else{
  25.                 if(x<=MIN3 && x>MIN2){
  26.                 MIN3=x;
  27.                 }
  28.             }
  29.         }
  30.  
  31.  
  32.     }
  33.     cout<< MIN3 << " " << MIN2 << " " <<MIN1;
  34.  
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment