Rezultati

Up. imeNalogaJezikRezultatČas oddaje
CryADsisAM Črte Java 0/100Prekoračen čas (TLE) 20. apr '17 @ 17:11

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 43,430 MiB 0,000 s OK
#2 10/10 52,563 MiB 0,000 s OK
#3 10/10 50,336 MiB 0,000 s OK
#4 10/10 111,059 MiB 0,959 s OK
#5 0/10 772,465 MiB 10,857 s Prekoračen čas
#6 0/10 443,156 MiB 10,136 s Prekoračen čas
#7 0/10 449,535 MiB 10,817 s Prekoračen čas
#8 0/10 446,109 MiB 10,900 s Prekoračen čas
#9 0/10 502,699 MiB 10,797 s Prekoračen čas
#10 0/10 967,969 MiB 10,805 s Prekoračen čas

Ocenjevani program (Main.java):
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> count = new ArrayList<>();
        Map<Double, Integer[]> map = new HashMap<>();
        int num = sc.nextInt();


        int c = 0;
        int[][] points = new int[num][2];
        for (int i = 0; i < num; i++) {
            points[i][0] = sc.nextInt();
            points[i][1] = sc.nextInt();
        }

        for (int i = 0; i < num - 1; i++) {
            for (int i2 = i + 1; i2 < num; i2++) {
                double len = Math.sqrt(Math.pow(points[i][0] - points[i2][0], 2) + Math.pow(points[i][1] - points[i2][1], 2));
                if (map.containsKey(len)) {
                    Integer[] val = map.get(len);
                    val[1] += val[0];
                    val[0]++;
                    map.put(len, val);
                } else {
                    Integer[] arr = {1, 0};
                    map.put(len, arr);
                }
            }
        }

        for (Integer[] i : map.values())
            c += i[1];

        System.out.println(c);
    }

}