結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
Ilag
|
| 提出日時 | 2020-07-22 22:40:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 864 bytes |
| コンパイル時間 | 1,671 ms |
| コンパイル使用メモリ | 167,608 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 23:29:26 |
| 合計ジャッジ時間 | 3,401 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 RE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin>>n;
ll a[n],b[n];
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
ll diff=0;
for(int i=0;i<n;i++)diff+=a[i]-b[i];
if(n==2){
if(a[0]-b[0]==b[1]-a[1])cout<<abs(a[0]-b[0])<<endl;
else cout<<-1<<endl;
}
if(diff%(n-2)!=0){
cout<<-1<<endl;
return 0;
}
ll cnt=diff/(n-2);
ll pls=0;
for(int i=0;i<n;i++){
ll d=a[i]-cnt;
ll e=b[i]-d;
if(e<0){
cout<<-1<<endl;
return 0;
}
pls+=e/2;
}
if(pls==cnt)cout<<cnt<<endl;
else cout<<-1<<endl;
}
Ilag