diff options
Diffstat (limited to 'šola/p1/dn/DN05_63230317.java')
-rw-r--r-- | šola/p1/dn/DN05_63230317.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/šola/p1/dn/DN05_63230317.java b/šola/p1/dn/DN05_63230317.java new file mode 100644 index 0000000..b46b5d1 --- /dev/null +++ b/šola/p1/dn/DN05_63230317.java @@ -0,0 +1,60 @@ +import java.util.*; +public class DN05_63230317 { + public static void main (String[] args) { + Scanner sc = new Scanner(System.in); + int[/* tetromino */][/* zgoraj=0 spodaj=1 */][/* stolpec */] tetro = { + {{0, 0, 0, 0}, {1, 1, 1, 1}} // 0 + ,{{0}, {4}} // 1 + ,{{0, 0}, {2, 2}} // 2 + ,{{1, 0, 1}, {2, 2, 2}} // 3 + ,{{1, 0}, {2, 3}} // 4 + ,{{0, 0, 0}, {1, 2, 1}} // 5 + ,{{0, 1}, {3, 2}} // 6 + ,{{0, 2}, {3, 3}} // 7 + ,{{1, 1, 0}, {2, 2, 2}} // 8 + ,{{0, 0}, {1, 3}} // 9 + ,{{0, 0, 0}, {2, 1, 1}} // 10 + ,{{2, 0}, {3, 3}} // 11 + ,{{0, 0, 0}, {1, 1, 2}} // 12 + ,{{0, 0}, {3, 1}} // 13 + ,{{0, 1, 1}, {2, 2, 2}} // 14 + ,{{0, 0, 1}, {1, 2, 2}} // 15 + ,{{1, 0}, {3, 2}} // 16 + ,{{1, 0, 0}, {2, 2, 1}} // 17 + ,{{0, 1}, {2, 3}} // 18 + }; + int višine[] = new int[2005]; + int n = sc.nextInt(); + for (int unused = 0; unused < n; unused++) { + int l = sc.nextInt(); + int x = sc.nextInt()+1000; + int najbližji = 69; + for (int i = 0; i < tetro[l][0].length; i++) { + if (najbližji == 69 || višine[x+i]+tetro[l][1][i] > višine[x+najbližji]+tetro[l][1][najbližji]) + najbližji = i; + } + if (System.getenv("DN05_DEBUG") != null) { + System.err.println("pade tetromino broj " + l + " na " + (x-1000) + " in stanje je"); + System.err.println("najbližji je " + najbližji); + } + višine[x+najbližji] += tetro[l][1][najbližji] - tetro[l][0][najbližji]; + for (int i = 0; i < tetro[l][0].length; i++) { + if (i == najbližji) + continue; + višine[x+i] = višine[x+najbližji]+tetro[l][0][najbližji]-tetro[l][0][i]; + } + if (System.getenv("DN05_DEBUG") != null) { + for (int i = 0; i < višine.length; i++) { + if (višine[i] == 0) + continue; + System.err.println((i-1000) + ": " + višine[i]); + } + } + } + for (int i = 0; i < višine.length; i++) { + if (višine[i] == 0) + continue; + System.out.println((i-1000) + ": " + višine[i]); + } + } +} |