Created
          December 30, 2019 17:48 
        
      - 
      
- 
        Save dalcon10028/e8815fe9a0dfa3f632fedd4f2fdecac6 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.*; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int N = sc.nextInt(); | |
| int []A = new int[N]; | |
| int []B = new int[N]; | |
| int S=0; | |
| for(int i=0; i<N; i++) | |
| A[i] = sc.nextInt(); | |
| for(int i=0; i<N; i++) | |
| B[i] = sc.nextInt(); | |
| sc.close(); | |
| Arrays.sort(A); | |
| Arrays.sort(B); | |
| for(int i=0; i<N; i++) | |
| S += A[i]*B[N-i-1]; | |
| System.out.print(S); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment