結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
IKyopro
|
| 提出日時 | 2020-07-22 21:27:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 931 bytes |
| コンパイル時間 | 2,055 ms |
| コンパイル使用メモリ | 195,280 KB |
| 最終ジャッジ日時 | 2025-01-12 02:09:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vec<ll> A(N),B(N);
ll asum = 0,bsum = 0;
for(auto& x:A){
cin >> x;
asum += x;
}
for(auto& x:B){
cin >> x;
bsum += x;
}
if(N==2){
ll d0 = A[0]-B[0],d1 = A[1]-B[1];
cout << ((d0+d1==0)? abs(d0):-1) << "\n";
return 0;
}
if((asum-bsum)%(N-2)!=0){
cout << -1 << "\n";
return 0;
}
ll ans = (asum-bsum)/(N-2);
ll cnt = 0;
for(int i=0;i<N;i++){
ll d = B[i]-A[i];
if((ans+d)%2){
cout << -1 << "\n";
return 0;
}
cnt += (ans+d)/2;
}
cerr << ans << " " << cnt << "\n";
cout << (ans==cnt? ans:-1) << "\n";
}
IKyopro