From b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sat, 18 Nov 2023 23:18:47 +0100 Subject: DN04 --- "\305\241ola/p1/dn/DN04_63230317.java" | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "\305\241ola/p1/dn/DN04_63230317.java" (limited to 'šola/p1') diff --git "a/\305\241ola/p1/dn/DN04_63230317.java" "b/\305\241ola/p1/dn/DN04_63230317.java" new file mode 100644 index 0000000..55c8b75 --- /dev/null +++ "b/\305\241ola/p1/dn/DN04_63230317.java" @@ -0,0 +1,31 @@ +import java.util.*; +public class DN04_63230317 { + public static void main (String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int k = sc.nextInt(); + int[] oznake_pojavitve = new int[1000]; + int[] seznam_oznak = new int[n]; + int max_oznaka = 0; // samo za DEBUG + for (int i = 0; i < n; i++) { + int oznaka = sc.nextInt(); + oznake_pojavitve[oznaka-1]++; + seznam_oznak[i] = oznaka; + if (oznaka > max_oznaka) // samo za DEBUG + max_oznaka = oznaka; // samo za DEBUG + } + if (System.getenv("DN04_DEBUG") != null) { + for (int i = 0; i < max_oznaka; i++) + System.err.print(i+1 + "\t"); + System.err.println(""); + for (int i = 0; i < max_oznaka; i++) + System.err.print(oznake_pojavitve[i] + "\t"); + System.err.println(""); + } + long parov = 0; + for (int i = 0; i < n; i++) + if (k-seznam_oznak[i]-1 >= 0 && k-seznam_oznak[i]-1 < 1000) + parov += oznake_pojavitve[k-seznam_oznak[i]-1]; + System.out.println(parov); + } +} -- cgit v1.2.3