結果

問題 No.1120 Strange Teacher
ユーザー auauaauaua
提出日時 2020-07-22 21:47:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 1,000 ms
コード長 1,096 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 165,976 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-09-04 17:24:43
合計ジャッジ時間 3,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,504 KB
testcase_04 AC 59 ms
4,720 KB
testcase_05 AC 59 ms
4,624 KB
testcase_06 AC 59 ms
4,732 KB
testcase_07 AC 60 ms
4,560 KB
testcase_08 AC 60 ms
4,656 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 60 ms
4,620 KB
testcase_11 AC 60 ms
4,712 KB
testcase_12 AC 60 ms
4,868 KB
testcase_13 AC 59 ms
4,640 KB
testcase_14 AC 59 ms
4,684 KB
testcase_15 AC 59 ms
4,576 KB
testcase_16 AC 60 ms
4,684 KB
testcase_17 AC 59 ms
4,876 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 65 ms
4,556 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 50 ms
4,544 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n;cin>>n;
    ll s=0;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    rep(i,n){
        cin>>b[i];
        s-=b[i];
    }
    if(n==2){
        if(s==0){
            cout<<abs(a[0]-b[0])<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }
    if(s%(n-2)){
        cout<<-1<<endl;
        return 0;
    }
    ll ma=0;
    bool f=1;
    s/=(n-2);
    rep(i,n){
        ll d=abs(a[i]-b[i]);
        if(d>s)f=0;
        if(s%2!=d%2){
            f=0;
        }
    }
    if(f)cout<<s<<endl;
    else cout<<-1<<endl;
}
0