結果
| 問題 | No.1686 Geschenkt |
| コンテスト | |
| ユーザー |
みーすけ
|
| 提出日時 | 2021-10-03 14:03:27 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 109 ms / 2,000 ms |
| コード長 | 472 bytes |
| 記録 | |
| コンパイル時間 | 4,170 ms |
| コンパイル使用メモリ | 82,068 KB |
| 実行使用メモリ | 47,476 KB |
| 最終ジャッジ日時 | 2026-04-03 03:58:27 |
| 合計ジャッジ時間 | 6,439 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge4_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
ソースコード
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
Arrays.sort(a);
int sum = a[0];
for (int i = n - 1; i > 0; i--) {
if (a[i - 1] != a[i] - 1)
sum += a[i];
}
System.out.println(sum);
}
}
みーすけ