Rezultati

Up. imeNalogaJezikRezultatČas oddaje
DROPTABLE-2017 Škatle C# 100/100OK 20. apr '17 @ 19:23

Test Točke Porabljen spomin Porabljen čas Status
#1 6/6 18,691 MiB 0,000 s OK
#2 6/6 20,711 MiB 0,000 s OK
#3 6/6 20,691 MiB 0,000 s OK
#4 6/6 20,660 MiB 0,000 s OK
#5 6/6 18,637 MiB 0,000 s OK
#6 7/7 18,605 MiB 0,000 s OK
#7 7/7 22,449 MiB 0,000 s OK
#8 7/7 20,633 MiB 0,000 s OK
#9 7/7 20,645 MiB 0,000 s OK
#10 7/7 20,691 MiB 0,000 s OK
#11 7/7 18,695 MiB 0,000 s OK
#12 7/7 20,707 MiB 0,000 s OK
#13 7/7 20,660 MiB 0,000 s OK
#14 7/7 18,668 MiB 0,000 s OK
#15 7/7 20,711 MiB 0,000 s OK

Ocenjevani program (Skatle3.cs):
// HULA HULA HOP reads from a file rather than stdin xD
// #define HULAHOP

using System;
using System.IO;
using System.Linq;

namespace csharp_template {
  class Program {

#if HULAHOP
    static string[] FILE_CONTENTS = File.ReadAllLines("tmp");
    static int FILE_LINE_CNT = 0;
#endif
    static string GetLine() {
#if HULAHOP
      return FILE_CONTENTS[FILE_LINE_CNT++];
#else
      return Console.ReadLine();
#endif
    }


    static int DIMCOUNT; // no. of dimneions
    static P[] boxes; // idk


    static bool CanWePlace(P p1, P p2) { // p1 into p2
      for (int i = DIMCOUNT - 1; i >= 0; i--)
        if (p1.Dimensions[i] >= p2.Dimensions[i])
          return false;
      return true;
    }


    class P : IComparable<P> {
      public int[] Dimensions; // sorted
      public int MaxSubBoxes = 1;

      public int CompareTo(P obj) {
        for (int i = 0; i < DIMCOUNT; i++) {
          if (this.Dimensions[i] > obj.Dimensions[i]) return 1;
          if (this.Dimensions[i] < obj.Dimensions[i]) return -1;
        }
        return 0;
      }
    }


    static void Main(string[] args) {
      var splitter = new char[] { ' ' };
      var fline = GetLine().Split(splitter);
      int boxcount = int.Parse(fline[0]);
      boxes = new P[boxcount];
      DIMCOUNT = int.Parse(fline[1]);
      for (int i = 0; i < boxcount; i++) {
        var dms = new int[DIMCOUNT];
        // var fsl = GetLine().Split(splitter).Select(t => int.Parse(t)).ToArray();
        var fls = GetLine().Split(splitter);
        for (int j = 0; j < DIMCOUNT; j++)
          dms[j] = int.Parse(fls[j]);
        Array.Sort(dms, (a, b) => b - a);
        boxes[i] = new P { Dimensions = dms };
      }
      int maxTotal = 1;
      Array.Sort(boxes, (b1, b2) => b2.CompareTo(b1));
      P prev = boxes[boxcount - 1];
      for (int i = boxcount - 1; i >= 0; i--) {
        var ibox = boxes[i];
        int max = ibox.MaxSubBoxes;
        for (int j = i + 1; j < boxcount; j++) {
          var jbox = boxes[j];
          if (CanWePlace(jbox, ibox)) {
            max = Math.Max(max, jbox.MaxSubBoxes + 1);
          }
        }
        ibox.MaxSubBoxes = max;
        maxTotal = Math.Max(max, maxTotal);
      }
      Console.WriteLine(maxTotal);
    }


  }
}