結果
問題 | No.1120 Strange Teacher |
ユーザー | bluemegane |
提出日時 | 2021-05-01 16:18:46 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,262 bytes |
コンパイル時間 | 1,127 ms |
コンパイル使用メモリ | 67,900 KB |
実行使用メモリ | 42,196 KB |
最終ジャッジ日時 | 2023-09-27 06:12:52 |
合計ジャッジ時間 | 8,019 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 59 ms
21,452 KB |
testcase_10 | AC | 131 ms
41,452 KB |
testcase_11 | AC | 133 ms
39,368 KB |
testcase_12 | AC | 130 ms
41,372 KB |
testcase_13 | AC | 131 ms
41,392 KB |
testcase_14 | AC | 130 ms
41,312 KB |
testcase_15 | AC | 128 ms
37,376 KB |
testcase_16 | AC | 132 ms
41,328 KB |
testcase_17 | AC | 134 ms
37,248 KB |
testcase_18 | AC | 60 ms
23,508 KB |
testcase_19 | AC | 137 ms
42,196 KB |
testcase_20 | AC | 59 ms
21,676 KB |
testcase_21 | AC | 60 ms
21,572 KB |
testcase_22 | AC | 59 ms
21,624 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 60 ms
21,628 KB |
testcase_26 | AC | 60 ms
21,632 KB |
testcase_27 | AC | 60 ms
21,668 KB |
testcase_28 | AC | 60 ms
23,468 KB |
testcase_29 | AC | 60 ms
23,428 KB |
ソースコード
using System.Linq; using static System.Math; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, long.Parse); line = Console.ReadLine().Trim().Split(' '); var b = Array.ConvertAll(line, long.Parse); if (n == 2) getAns2(n, a, b); else getAns3(n, a, b); } static void getAns2(int n, long[] a, long[] b) { if (a.Sum() != b.Sum()) { Console.WriteLine(-1); return; } Console.WriteLine(Abs(a[0] - b[0])); } static void getAns3(int n, long[] a, long[] b) { var d = a.Sum() - b.Sum(); if (d % (n - 2L) != 0) { Console.WriteLine(-1); return; } var t = d / (n - 2L); for (int i = 0; i < n; i++) a[i] -= t; var count = 0L; for (int i = 0; i < n; i++) { var w = b[i] - a[i]; if (w < 0) { Console.WriteLine(-1); return; } if (w > 0) { if (w % (n - 2L) != 0) { Console.WriteLine(-1); return; } else count += w / (n - 2L); } } if (count == t) Console.WriteLine(t); } }