diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-11-18 23:18:47 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-11-18 23:18:47 +0100 |
commit | b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe (patch) | |
tree | 6de82dfa3b483d7d193112d0306e69c7cd423ead | |
parent | dn03 (diff) | |
download | r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.tar r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.tar.gz r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.tar.bz2 r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.tar.lz r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.tar.xz r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.tar.zst r-b7e06e086be6d0fea2dde4c766ad8cedb4fe94fe.zip |
-rw-r--r-- | šola/p1/dn/DN04_63230317.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/šola/p1/dn/DN04_63230317.java b/šola/p1/dn/DN04_63230317.java new file mode 100644 index 0000000..55c8b75 --- /dev/null +++ b/šola/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); + } +} |