Example:
Input:
4
1 3 3 4
Output:
9
Because 3 X 3 = 9 and this is a maximum area
import java.io.*;
import java.util.*;
public class R {
static int max(int[] a) {
int max = 0;
for (int i = 0; i < a.length; i++) {
if ( a[i] > max ) {
max = a[i];
}
}
return max;
}
static int min(int[] a) {
int min = 50000;
for (int i = 0; i < a.length; i++) {
if (a[i] < min) {
min = a[i];
}
}
return min;
}
static int leiaPohjaPindala(int[] a, int n) {
int vahim, tulemus;
vahim = min(a);
tulemus = vahim * n;
return tulemus;
}
public static void main(String args[]) throws Exception {
Scanner sisend = new Scanner(new FileReader("rek.sis"));
PrintWriter valjund = new PrintWriter(new BufferedWriter(new FileWriter("rek.out")));
int N = sisend.nextInt();
int[] temp = new int[N];
for (int i = 0; i < N; i++) {
temp[i] = sisend.nextInt();
}
sisend.close();
int maxI = max(temp);
int suurim, suurim1;
for (int i = 0; i < maxI; i++) {
for (int j = i + 1; j < maxI; j++) {
suurim = leiaPohjaPindala(temp, i);
suurim1 = leiaPohjaPindala(temp, j);
valjund.println(suurim);
valjund.println(suurim1);
}
}
valjund.close();
}
}