結果
問題 | No.625 ソンタクロース |
ユーザー | ikd |
提出日時 | 2018-01-05 02:13:06 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 79 ms / 4,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 1,843 ms |
コンパイル使用メモリ | 150,144 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2024-06-12 23:19:33 |
合計ジャッジ時間 | 3,157 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.typecons; int n, m; rd(n, m); auto as=[m]; alias T=Tuple!(size_t, "i", int, "y"); foreach(_; 0..(n-1)){ T[] bs; foreach(i, a; as) bs~=T(i, a+1); sort!((l, r)=>(l.y==r.y ? l.i>r.i : l.y<r.y))(bs); auto k=(bs.length+1)/2; auto nex=new int[](as.length); foreach(b; bs[0..k]) nex[b.i]=b.y; auto s=sum(nex); if(s<=m) as=(m-s)~nex; else as=(-1)~as; } writefln("%(%s %)", as); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } } void wr(T...)(T x){ import std.stdio; foreach(e; x) write(e, " "); writeln(); }