結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
![]() |
提出日時 | 2020-07-23 00:24:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 847 bytes |
コンパイル時間 | 1,485 ms |
コンパイル使用メモリ | 168,724 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 02:53:53 |
合計ジャッジ時間 | 3,663 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<ll> a(n), b(n); for(ll i = 0; i < n; i++)cin >> a[i]; for(ll i = 0; i < n; i++)cin >> b[i]; ll sum = 0, k = 0, use = 0; for(ll i = 0; i < n; i++) sum += (a[i] - b[i]); if(n == 2 && sum) { cout << -1 << endl; return 0; }else if(n == 2 && sum == 0) { cout << abs(a[0] - b[0]) << endl; return 0; } if(sum % (n - 2)) { cout << -1 << endl; return 0; } k = sum / (n - 2); for(ll i = 0; i < n; i++) { if((b[i] - a[i] + k) % 2) { cout << -1 << endl; return 0; } use += (b[i] - a[i] + k) / 2; } if(use != k) { cout << -1 << endl; return 0; } cout << k << endl; }