結果
問題 | No.989 N×Mマス計算(K以上) |
ユーザー | Mishan5055 |
提出日時 | 2020-02-25 17:42:43 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,506 bytes |
コンパイル時間 | 2,441 ms |
コンパイル使用メモリ | 78,724 KB |
実行使用メモリ | 60,348 KB |
最終ジャッジ日時 | 2024-04-21 13:48:27 |
合計ジャッジ時間 | 8,031 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
46,740 KB |
testcase_01 | AC | 132 ms
41,452 KB |
testcase_02 | AC | 142 ms
41,384 KB |
testcase_03 | AC | 146 ms
41,284 KB |
testcase_04 | AC | 124 ms
40,336 KB |
testcase_05 | AC | 141 ms
41,192 KB |
testcase_06 | AC | 141 ms
41,264 KB |
testcase_07 | AC | 139 ms
41,464 KB |
testcase_08 | AC | 138 ms
41,340 KB |
testcase_09 | AC | 144 ms
41,620 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1,713 ms
60,348 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
import java.util.*; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int M=sc.nextInt(); int K=sc.nextInt(); String str=sc.next(); PriorityQueue<Integer> pq=new PriorityQueue<>(); int[] B=new int[M]; int[] Binv=new int[M]; for(int i=0;i<M;i++){ pq.add(sc.nextInt()); } long ANS=0L; if(str.equals("+")){ for(int i=0;i<M;i++){ B[M-1-i]=pq.poll(); Binv[M-1-i]=K-B[M-1-i]; } for(int i=0;i<N;i++){ int A=sc.nextInt(); for(int j=0;j<M;j++){ if(A<Binv[j]){ ANS+=j; break; }else if(j==M-1){ ANS+=M; } } } }else{ for(int i=0;i<M;i++){ B[M-1-i]=pq.poll(); Binv[M-1-i]=(K+B[M-1-i]-1)/B[M-1-i]; } for(int i=0;i<N;i++){ int A=sc.nextInt(); for(int j=0;j<M;j++){ if(A<Binv[j]){ ANS+=j; break; }else if(j==M-1){ ANS+=M; } } } } System.out.println(ANS); } }