結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-22 21:27:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,169 bytes |
| コンパイル時間 | 2,243 ms |
| コンパイル使用メモリ | 89,256 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 13:30:32 |
| 合計ジャッジ時間 | 3,333 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;
void ok(){
cout << "Yes" << endl;
exit(0);
}
void ng(){
cout << "-1" << endl;
exit(0);
}
Int n;
Int a[110000], b[110000];
Int ans;
int main(){
cin >> n;
Int suma = 0, sumb = 0;
for(int i = 0;i < n;i++){cin >> a[i];suma += a[i];}
for(int i = 0;i < n;i++){cin >> b[i];sumb += b[i];}
if(n == 2){
if(suma != sumb)ng();
cout << abs(a[0] - b[0]) << endl;
return 0;
}
if((suma - sumb) % (n-2) != 0)ng();
if(suma < sumb)ng();
Int cnt = (suma - sumb) / (n-2);
for(int i = 0;i < n;i++){
Int dif = b[i] - (a[i] - cnt);
if(dif % 2 == 1)ng();
ans += dif / 2;
}
cout << ans << endl;
return 0;
}