Advertisement
ahmed_ashraf

Untitled

Jul 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.Scanner;
  4.  
  5. public class p3 {
  6.  
  7.     public static void main(String[] args) {
  8.         // TODO Auto-generated method stub
  9.        
  10.        
  11.         Scanner s = new Scanner(System.in);
  12.        
  13.         int n = s.nextInt();
  14.         int k = s.nextInt();
  15.        
  16.         ArrayList<Long> arr = new ArrayList<>();
  17.         ArrayList<Long> arr1 = new ArrayList<>();
  18.        
  19.         for(int i = 0; i < n; i++) {
  20.             long t = s.nextLong();
  21.             arr.add(t);
  22.             arr1.add(t);
  23.         }
  24.         Collections.sort(arr);
  25.         long max = arr.get(arr.size() - 1);
  26.        
  27.  
  28.         if(k == 1) {
  29.             System.out.println(arr.get(0));
  30.         }
  31.         else if(k == 2) {
  32.            
  33.         }
  34.            
  35.            
  36.         }
  37.        
  38.        
  39.        
  40.        
  41.        
  42.        
  43.        
  44.        
  45.        
  46.  
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement