結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
|
提出日時 | 2022-10-10 06:01:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 853 bytes |
コンパイル時間 | 1,993 ms |
コンパイル使用メモリ | 196,404 KB |
最終ジャッジ日時 | 2025-02-08 01:08:12 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 2 RE * 3 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); ll N; cin >> N; vector<ll> A(N), B(N); rep(i,N) cin >> A[i]; rep(i,N) cin >> B[i]; // N-2ずつ減る ll sumA = accumulate(A.begin(), A.end(), 0LL); ll sumB = accumulate(B.begin(), B.end(), 0LL); if((sumB - sumA) % (N - 2) != 0) { cout << -1 << endl; return 0; } ll K = (sumA - sumB) / (N - 2); ll cnt = 0; rep(i,N) { // x + y = K // x - y = B - A // 2x = K + B - A // 2y = K - B + A if((K + B[i] - A[i]) % 2 != 0){ cout << -1 << endl; return 0; } cnt += (K + B[i] - A[i]) / 2; } if(cnt == K) { cout << cnt << endl; } else { cout << -1 << endl; } }