結果
問題 | No.918 LISGRID |
ユーザー | 37zigen |
提出日時 | 2020-03-11 15:46:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 394 ms / 2,000 ms |
コード長 | 1,629 bytes |
コンパイル時間 | 3,139 ms |
コンパイル使用メモリ | 80,240 KB |
実行使用メモリ | 63,384 KB |
最終ジャッジ日時 | 2023-08-10 01:34:52 |
合計ジャッジ時間 | 17,272 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 160 ms
56,736 KB |
testcase_01 | AC | 324 ms
63,156 KB |
testcase_02 | AC | 292 ms
59,196 KB |
testcase_03 | AC | 304 ms
61,768 KB |
testcase_04 | AC | 291 ms
59,596 KB |
testcase_05 | AC | 376 ms
61,428 KB |
testcase_06 | AC | 360 ms
61,516 KB |
testcase_07 | AC | 346 ms
60,824 KB |
testcase_08 | AC | 362 ms
61,220 KB |
testcase_09 | AC | 374 ms
62,092 KB |
testcase_10 | AC | 342 ms
62,128 KB |
testcase_11 | AC | 355 ms
59,880 KB |
testcase_12 | AC | 380 ms
61,640 KB |
testcase_13 | AC | 394 ms
63,100 KB |
testcase_14 | AC | 350 ms
62,404 KB |
testcase_15 | AC | 378 ms
59,840 KB |
testcase_16 | AC | 312 ms
61,960 KB |
testcase_17 | AC | 340 ms
61,764 KB |
testcase_18 | AC | 337 ms
63,384 KB |
testcase_19 | AC | 272 ms
60,108 KB |
testcase_20 | AC | 357 ms
61,728 KB |
testcase_21 | AC | 275 ms
59,568 KB |
testcase_22 | AC | 269 ms
59,560 KB |
testcase_23 | AC | 313 ms
60,080 KB |
testcase_24 | AC | 198 ms
56,944 KB |
testcase_25 | AC | 174 ms
57,068 KB |
testcase_26 | AC | 158 ms
56,828 KB |
testcase_27 | AC | 150 ms
56,712 KB |
testcase_28 | AC | 153 ms
57,148 KB |
testcase_29 | AC | 155 ms
56,656 KB |
testcase_30 | AC | 159 ms
56,960 KB |
testcase_31 | AC | 156 ms
57,052 KB |
testcase_32 | AC | 160 ms
56,608 KB |
testcase_33 | AC | 161 ms
56,880 KB |
testcase_34 | AC | 195 ms
57,376 KB |
testcase_35 | AC | 224 ms
57,420 KB |
testcase_36 | AC | 179 ms
57,028 KB |
testcase_37 | AC | 368 ms
62,336 KB |
testcase_38 | AC | 297 ms
60,456 KB |
ソースコード
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); int[] A=new int[H]; int[] B=new int[W]; int[][] m=new int[H][W]; for(int h=0;h<H;++h)for(int w=0;w<W;++w)m[h][w]=-1; for(int i=0;i<A.length;++i) { A[i]=-sc.nextInt(); } for(int i=0;i<B.length;++i) { B[i]=-sc.nextInt(); } Arrays.sort(A); Arrays.sort(B); for(int i=0;i<A.length;++i)A[i]*=-1; for(int i=0;i<B.length;++i)B[i]*=-1; int s=1,t=H*W; for(int h=0;h<H;++h) { int bottom=0,top=0; for(int w=0;w<W;++w) { if(B[w]>1)++bottom; else ++top; } if(A[h]>1) { int left=Math.min(bottom,(top==0?A[h]:(A[h]-1))); int right=A[h]-left; for(int w=0;w<left;++w) { m[h][bottom-left+w]=s++; } for(int w=0;w<bottom-left;++w) { m[h][bottom-left-1-w]=s++; } for(int w=0;w<top-right;++w) { m[h][bottom+w]=t--; } for(int w=0;w<right;++w) { m[h][W-1-w]=t--; } }else { for(int w=0;w<W;++w) { s=t-(H-h)+1; int t_=t; for(int i=h;i<H;++i) { if(B[w]>1) { {m[i][w]=s++;B[w]--;} }else m[i][w]=t--; } t=t_-(H-h); } break; } for(int w=0;w<W;++w)B[w]=Math.max(B[w]-1, 1); } PrintWriter pw=new PrintWriter(System.out); for(int h=0;h<H;++h) { for(int w=0;w<W;++w) { pw.print(m[h][w]+(w==W-1?"\n":" ")); } } pw.close(); } void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));} }