結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-06-27 12:51:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 865 bytes |
| コンパイル時間 | 570 ms |
| コンパイル使用メモリ | 72,876 KB |
| 最終ジャッジ日時 | 2025-02-15 02:35:31 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main(){
long long n;cin>>n;
vector<long long> A(n), B(n);
for(int i = 0; n > i; i++){
cin>>A[i];
}
for(int i = 0; n > i; i++){
cin>>B[i];
}
if(n == 2){
if(A[0]+A[1] == B[0]+B[1]){
cout << abs(A[0]-B[0]) << endl;
}else{
cout << -1 << endl;
}
}else{
long long dif = 0;
for(int i = 0; n > i; i++){
dif += A[i]-B[i];
}
if(dif < 0 || dif%(n-2)){
cout << -1 << endl;
return 0;
}
long long c = dif/(n-2);
long long nw = 0;
for(int i = 0; n > i; i++){
long long mn = A[i]-c;
if((B[i]-mn)%2){
cout << -1 << endl;
return 0;
}
nw += (B[i]-mn)/2;
}
if(nw == c){
cout << c << endl;
}else{
cout << -1 << endl;
}
}
}
//444 711 620 511 220 111