結果
問題 | No.112 ややこしい鶴亀算 |
ユーザー |
![]() |
提出日時 | 2017-01-22 21:06:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 179 ms / 5,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 2,533 ms |
コンパイル使用メモリ | 86,428 KB |
実行使用メモリ | 42,524 KB |
最終ジャッジ日時 | 2024-12-23 05:42:57 |
合計ジャッジ時間 | 7,773 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numAnimals = sc.nextInt(); int legs[] = new int[numAnimals]; int legsSum = 0; for (int i = 0; i < numAnimals; i++) { legs[i] = sc.nextInt(); legsSum += legs[i]; } legsSum /= numAnimals - 1; int cranesCount = 0; int turtlesCount = 0; for (int i = 0; i < numAnimals; i++) { if (legsSum - legs[i] == 2) { cranesCount++; } if (legsSum - legs[i] == 4) { turtlesCount++; } } System.out.println(cranesCount + " " + turtlesCount); } }