結果

問題 No.1120 Strange Teacher
ユーザー kyoprounokyoprouno
提出日時 2020-07-23 01:15:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,206 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 175,528 KB
実行使用メモリ 4,904 KB
最終ジャッジ日時 2023-09-05 08:00:01
合計ジャッジ時間 5,569 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 AC 60 ms
4,580 KB
testcase_05 AC 61 ms
4,896 KB
testcase_06 AC 59 ms
4,692 KB
testcase_07 AC 60 ms
4,588 KB
testcase_08 AC 60 ms
4,632 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 61 ms
4,904 KB
testcase_11 AC 61 ms
4,764 KB
testcase_12 AC 60 ms
4,604 KB
testcase_13 AC 61 ms
4,640 KB
testcase_14 AC 60 ms
4,552 KB
testcase_15 AC 59 ms
4,588 KB
testcase_16 AC 59 ms
4,636 KB
testcase_17 AC 60 ms
4,632 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 66 ms
4,584 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 52 ms
4,684 KB
testcase_25 RE -
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    ll sum_a=0,sum_b=0,sum_c=0;
    rep(i,n){
        cin >> a[i];
        sum_a+=a[i];
    }
    rep(i,n){
        cin >> b[i];
        sum_b+=b[i];
    }
    ll cnt=(sum_a-sum_b)/(n-2); //操作回数の和
    bool ok=true;
    rep(i,n){
        ll x=cnt+b[i]-a[i];
        if(x%2==1  || x<0){
            ok=false;
            break;
        }
        else{
            sum_c+=(x/2);
        }
        
    }
    if(sum_c!=cnt) ok=false;
    if(ok) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}
0