結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
poohbear
|
| 提出日時 | 2020-07-23 20:49:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,079 bytes |
| コンパイル時間 | 2,055 ms |
| コンパイル使用メモリ | 194,428 KB |
| 最終ジャッジ日時 | 2025-01-12 04:29:57 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
int main(){
int n;
cin >> n;
vector<ll>a(n),b(n);
ll sa=0,sb=0;
rep(i,n){
cin>>a[i];
sa+=a[i];
}
rep(i,n){
cin>>b[i];
sb+=b[i];
}
if(n==2){
if((sa+sb)%2==0){
cout << abs(a[0]-b[0]) << endl;
return 0;
}
else{
cout << -1 << endl;
return 0;
}
}
if((sa-sb)%(n-2)!=0){
cout << -1 << endl;
return 0;
}
ll c = (sa-sb)/(n-2);
rep(i,n){
ll ci = a[i]-b[i]+c;
if(ci<0||ci%2==1){
cout << -1 << endl;
return 0;
}
}
cout << c << endl;
return 0;
}
poohbear