結果

問題 No.165 四角で囲え!
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-30 21:02:40
言語 Crystal
(1.11.2)
結果
AC  
実行時間 972 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 20,422 ms
コンパイル使用メモリ 258,084 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-13 10:03:15
合計ジャッジ時間 30,073 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 394 ms
5,124 KB
testcase_01 AC 3 ms
4,456 KB
testcase_02 AC 3 ms
4,444 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,436 KB
testcase_05 AC 556 ms
5,256 KB
testcase_06 AC 119 ms
5,008 KB
testcase_07 AC 2 ms
4,408 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,392 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 560 ms
5,004 KB
testcase_12 AC 806 ms
5,200 KB
testcase_13 AC 818 ms
5,136 KB
testcase_14 AC 793 ms
5,148 KB
testcase_15 AC 744 ms
5,212 KB
testcase_16 AC 819 ms
5,248 KB
testcase_17 AC 734 ms
5,144 KB
testcase_18 AC 972 ms
5,164 KB
testcase_19 AC 760 ms
5,164 KB
testcase_20 AC 737 ms
5,152 KB
testcase_21 AC 733 ms
5,196 KB
testcase_22 AC 738 ms
5,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,b=gets.not_nil!.split.map &.to_i
a=(0...n).map{gets.not_nil!.split.map &.to_i}
x=a.map{|c|c[0]}.sort.uniq
a.map{|c|c[0]=x.index(c[0]).not_nil!}
z=0
n.times{|i|n.times{|j|
  f=[0]*n
  g=[0]*n
  n.times{|k|a[i][1]<=a[k][1]&&a[k][1]<=a[j][1]&&(f[a[k][0]]+=1;g[a[k][0]]+=a[k][2])}
  s=t=0
  l=0
  n.times{|k|
    s+=f[k]
    t+=g[k]
    while t>b
      s-=f[l];t-=g[l];l+=1
    end
    z=s if z<s
  }
}}
p z
0