結果
| 問題 |
No.989 N×Mマス計算(K以上)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-25 18:21:38 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,058 ms / 2,000 ms |
| コード長 | 1,071 bytes |
| コンパイル時間 | 2,512 ms |
| コンパイル使用メモリ | 79,380 KB |
| 実行使用メモリ | 59,884 KB |
| 最終ジャッジ日時 | 2024-10-13 12:37:31 |
| 合計ジャッジ時間 | 12,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
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();
Integer[] B=new Integer[M];
Integer[] A=new Integer[N];
for(int i=0;i<M;i++){
B[i]=sc.nextInt();
}
Arrays.sort(B,Collections.reverseOrder());
for(int i=0;i<N;i++){
A[i]=sc.nextInt();
}
Arrays.sort(A,Collections.reverseOrder());
long ANS=0;
int idxB=M-1;
if(str.equals("+")){
for(int j=0;j<N;j++){
while(idxB>=0&&B[idxB]+A[j]<K){
idxB--;
}
ANS+=idxB+1;
}
}else{
for(int j=0;j<N;j++){
while(idxB>=0&&B[idxB]*A[j]<K){
idxB--;
}
ANS+=idxB+1;
}
}
System.out.println(ANS);
}
}