結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-07-10 23:52:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 825 bytes |
| コンパイル時間 | 778 ms |
| コンパイル使用メモリ | 68,736 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 20:54:58 |
| 合計ジャッジ時間 | 2,947 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 |
ソースコード
// writer 解の改変嘘解法
#include <iostream>
#include <cmath>
using namespace std;
long long N, A[1 << 18], B[1 << 18];
int main() {
cin >> N;
for (int i = 1; i <= N; i++) cin >> A[i];
for (int i = 1; i <= N; i++) cin >> B[i];
if (N == 2LL) {
long long ans = abs(A[1] - B[1]);
// if (A[1] + A[2] != B[1] + B[2]) ans = -1;
cout << ans << endl;
return 0;
}
long long S = 0;
for (int i = 1; i <= N; i++) S += A[i];
for (int i = 1; i <= N; i++) S -= B[i];
if (S < 0 || S % (N - 2LL) != 0) { cout << "-1" << endl; return 0; }
S /= (N - 2LL);
long long cnt = 0;
for (int i = 1; i <= N; i++) {
long long eval = B[i] - (A[i] - S);
if (eval % 2 == 1 || eval < 0) { cout << "-1" << endl; return 0; }
cnt += (eval / 2LL);
}
if (cnt != S) cout << "-1" << endl;
else cout << S << endl;
return 0;
}
maspy