icez

Untitled

Feb 3rd, 2013
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. $in = file('shop.txt');
  3.  
  4. $count = trim($in[0]) + 0;
  5. unset ($in[0]);
  6.  
  7. $testset = array();
  8. $i = 0;
  9. $intestset = false;
  10. foreach ($in as $line ){
  11.     $line = trim($line) + 0;
  12.     if (!$intestset) {
  13.         $intestset = true;
  14.         $testsetmax = $line;
  15.         if ($i > 0) ksort($testset[$i]);
  16.         $i++;
  17.         $testsetcount = 0;
  18.         $testset[$i] = array();
  19.     } else {
  20.         $testsetcount++;
  21.         if (!isset($testset[$i][$line])) $testset[$i][$line] = 0;
  22.         $testset[$i][$line]++;
  23.         if ($testsetcount == $testsetmax) {
  24.             $intestset = false;
  25.         }
  26.     }
  27. }
  28. ksort($testset[$i]);
  29.  
  30. foreach ($testset as $i => $tests) {
  31.     $curmaxrange = 0;
  32.     $curstart = -1;
  33.     $testarr = $tests;
  34.     $rangecount = array();
  35.     foreach ($tests as $intime => $count) {
  36.         foreach($rangecount as $rtime => $rcount) {
  37.             if ($rtime + 59 < $intime) $rangecount[$rtime] += $count; // จะผิดก้ตรงเนี้ย ลองเทส 59 กับ 60 แล้ว แต่ยังไม่ได้เทส 58 -*-'
  38.         }
  39.         $rangecount[$intime] = $count;
  40.     }
  41. //  print_r($rangecount);
  42.     echo max($rangecount)."\n";
  43. }
Advertisement
Add Comment
Please, Sign In to add comment