結果

問題 No.1120 Strange Teacher
ユーザー IlagIlag
提出日時 2020-07-22 22:38:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 755 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 164,492 KB
実行使用メモリ 5,200 KB
最終ジャッジ日時 2023-09-05 02:35:27
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 21 ms
5,104 KB
testcase_05 AC 21 ms
4,920 KB
testcase_06 AC 22 ms
4,956 KB
testcase_07 AC 21 ms
4,988 KB
testcase_08 AC 22 ms
4,944 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 22 ms
4,924 KB
testcase_11 AC 22 ms
4,936 KB
testcase_12 AC 22 ms
4,992 KB
testcase_13 AC 21 ms
5,200 KB
testcase_14 AC 21 ms
5,004 KB
testcase_15 AC 21 ms
4,980 KB
testcase_16 AC 21 ms
5,068 KB
testcase_17 AC 22 ms
4,976 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 23 ms
4,948 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 19 ms
4,932 KB
testcase_25 RE -
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    ll diff=0;
    for(int i=0;i<n;i++)diff+=a[i]-b[i];
    if(diff%(n-2)!=0){
        cout<<-1<<endl;
        return 0;
    }
    ll cnt=diff/(n-2);
    ll pls=0;
    for(int i=0;i<n;i++){
        ll d=a[i]-cnt;
        ll e=b[i]-d;
        if(e<0){
            cout<<-1<<endl;
            return 0;
        }
        pls+=e/2;
    }
    if(pls==cnt)cout<<cnt<<endl;
    else cout<<-1<<endl;
}
0