結果
問題 |
No.989 N×Mマス計算(K以上)
|
ユーザー |
|
提出日時 | 2020-02-25 17:42:43 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,506 bytes |
コンパイル時間 | 2,192 ms |
コンパイル使用メモリ | 77,924 KB |
実行使用メモリ | 60,036 KB |
最終ジャッジ日時 | 2024-10-13 12:29:15 |
合計ジャッジ時間 | 7,537 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 TLE * 2 -- * 7 |
ソースコード
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); } }