結果
問題 |
No.989 N×Mマス計算(K以上)
|
ユーザー |
|
提出日時 | 2020-02-25 17:53:46 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,291 bytes |
コンパイル時間 | 2,055 ms |
コンパイル使用メモリ | 78,656 KB |
実行使用メモリ | 71,724 KB |
最終ジャッジ日時 | 2024-10-13 12:32:49 |
合計ジャッジ時間 | 12,714 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 WA * 2 TLE * 1 |
ソースコード
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[] Binv=new int[M]; for(int i=0;i<M;i++){ pq.add(sc.nextInt()); } long ANS=M*N; if(str.equals("+")){ for(int i=0;i<M;i++){ Binv[M-1-i]=K-pq.poll(); } for(int i=0;i<N;i++){ int A=sc.nextInt(); for(int j=0;j<M;j++){ if(A<Binv[j]){ ANS-=M-j; break; } } } }else{ for(int i=0;i<M;i++){ int s=pq.poll(); Binv[M-1-i]=(K+s-1)/s; } for(int i=0;i<N;i++){ int A=sc.nextInt(); for(int j=0;j<M;j++){ if(A<Binv[j]){ ANS-=M-j; break; } } } } System.out.println(ANS); } }