結果

問題 No.1120 Strange Teacher
コンテスト
ユーザー pockyny
提出日時 2020-07-22 21:41:45
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 676 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 418 ms
コンパイル使用メモリ 81,264 KB
実行使用メモリ 9,792 KB
最終ジャッジ日時 2026-10-13 15:42:11
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>

using namespace std;
typedef long long ll;
ll a[100010],b[100010];
int main(){
    int i; ll n; cin >> n;
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++) cin >> b[i];
    ll s1 = 0,s2 = 0;
    for(i=0;i<n;i++){
        s1 += a[i]; s2 += b[i];
    }
    if(s1<s2 || (s1 - s2)%(n - 2)!=0){
        cout << -1 << endl;
        return 0;
    }
    ll t = (s1 - s2)/(n - 2),tt = 0;
    for(i=0;i<n;i++){
        if((b[i] - a[i] + t<0) || (b[i] - a[i] + t)&1){
            cout << -1 << endl;
            return 0;
        }
        tt += (b[i] - a[i] + t)/2;
    }
    if(tt==t){
        cout << t << endl;
    }else{
        cout << -1 << endl;
    }
}
0