結果

問題 No.1120 Strange Teacher
ユーザー w2w2w2w2
提出日時 2020-07-22 22:00:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,461 bytes
コンパイル時間 3,123 ms
コンパイル使用メモリ 167,424 KB
実行使用メモリ 4,824 KB
最終ジャッジ日時 2023-09-04 20:06:37
合計ジャッジ時間 4,080 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 22 ms
4,672 KB
testcase_05 AC 22 ms
4,616 KB
testcase_06 AC 21 ms
4,556 KB
testcase_07 AC 22 ms
4,636 KB
testcase_08 AC 21 ms
4,612 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 22 ms
4,532 KB
testcase_17 AC 21 ms
4,568 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 RE -
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 19 ms
4,552 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 RE -
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    ll sum = 0;
    bool ok = 1;
    vector<ll> A(N);
    vector<ll> B(N);
    REP(i,N)cin >> A[i];
    REP(i,N)cin >> B[i];
    REP(i,N)sum += A[i] - B[i];
    ll count = 0;
    ll ans = 0;
    if(N == 2){
        if(A[0] + A[1] != B[0] + B[1]){
            ok = 0;
        }else{
            ans = abs(A[0] - B[0]);
        }
        cout << (ok ? ans : -1) << "\n";
    }else{
        if(sum % (N-2) != 0){
            ok = 0;
        }else{
            count = sum / (N-2);
        }
        REP(i,N){
            if(A[i] -B[i] - count > 0)ok = 0;
        }
        if(count < 0)ok = 0;
        cout << (ok ? count : -1) << "\n";
        if(count < 2)return -1;
    }
}
0