結果
| 問題 |
No.1692 Expectations
|
| コンテスト | |
| ユーザー |
みーすけ
|
| 提出日時 | 2021-10-01 21:44:14 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 969 ms / 2,000 ms |
| コード長 | 1,072 bytes |
| コンパイル時間 | 2,370 ms |
| コンパイル使用メモリ | 79,152 KB |
| 実行使用メモリ | 68,044 KB |
| 最終ジャッジ日時 | 2024-07-19 10:55:44 |
| 合計ジャッジ時間 | 12,358 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
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[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
int min = 0;
if(n==m && 1<=a[0] && a[0]<=m){
boolean allSame = true;
for (int i = 1; i < n; i++) {
if (a[i] != a[0]) {
allSame = false;
break;
}
}
if (allSame) {
min = 1;
}
}
int max = n;
HashSet<Integer> hs = new HashSet<Integer>();
for (int i = 0; i < n; i++) {
if (1 <= a[i] && a[i] <= m) {
if (hs.contains(a[i])) {
max--;
} else {
hs.add(a[i]);
}
} else {
max--;
}
}
System.out.println(max + " " + min);
}
}
みーすけ