結果
問題 | No.707 書道 |
ユーザー | Mcpu3 |
提出日時 | 2018-08-22 19:05:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 882 bytes |
コンパイル時間 | 2,077 ms |
コンパイル使用メモリ | 74,252 KB |
実行使用メモリ | 56,352 KB |
最終ジャッジ日時 | 2023-08-26 07:12:09 |
合計ジャッジ時間 | 4,091 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,980 KB |
testcase_01 | AC | 126 ms
55,856 KB |
testcase_02 | AC | 144 ms
55,968 KB |
testcase_03 | AC | 124 ms
55,544 KB |
testcase_04 | AC | 124 ms
55,772 KB |
testcase_05 | AC | 156 ms
56,084 KB |
testcase_06 | AC | 162 ms
56,352 KB |
testcase_07 | AC | 168 ms
56,260 KB |
testcase_08 | AC | 129 ms
55,644 KB |
ソースコード
import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); double m=Double.MAX_VALUE,t; int h=sc.nextInt(),w=sc.nextInt(),i,j,k; String p[]=new String[52]; for(i=1;i<=h;i++) p[i]=sc.next(); sc.close(); for(i=1;i<=w;i++) { t=0; for(j=1;j<=h;j++) for(k=0;k<w;k++) if(p[j].charAt(k)=='1') t+=Math.hypot(k-i+1, j); if(m>t) m=t; } for(i=1;i<=h;i++) { t=0; for(j=1;j<=h;j++) for(k=0;k<w;k++) if(p[j].charAt(k)=='1') t+=Math.hypot(k-w, j-i); if(m>t) m=t; } for(i=1;i<=w;i++) { t=0; for(j=1;j<=h;j++) for(k=0;k<w;k++) if(p[j].charAt(k)=='1') t+=Math.hypot(k-i+1, j-h-1); if(m>t) m=t; } for(i=1;i<=h;i++) { t=0; for(j=1;j<=h;j++) for(k=0;k<w;k++) if(p[j].charAt(k)=='1') t+=Math.hypot(k+1, j-i); if(m>t) m=t; } System.out.print(m); } }