結果

問題 No.1120 Strange Teacher
ユーザー IlagIlag
提出日時 2020-07-22 21:52:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 2,664 ms
コンパイル使用メモリ 163,436 KB
実行使用メモリ 5,128 KB
最終ジャッジ日時 2023-09-04 17:53:23
合計ジャッジ時間 3,242 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 22 ms
4,904 KB
testcase_11 AC 22 ms
4,840 KB
testcase_12 AC 22 ms
4,860 KB
testcase_13 AC 22 ms
4,848 KB
testcase_14 AC 23 ms
4,844 KB
testcase_15 AC 22 ms
4,940 KB
testcase_16 AC 22 ms
5,120 KB
testcase_17 AC 22 ms
5,012 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 24 ms
5,020 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 WA -
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],sum=0,sum2=0,ans=0;
    for(int i=0;i<n;i++)cin>>a[i];
    if(n==2){
        for(int i=0;i<n;i++)cin>>b[i];
        if(a[0]+a[1]==b[0]+b[1])cout<<abs(a[0]-b[0])<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        ll c=a[i]-b[i];
        sum+=c;
        sum2+=c;
        ans+=sum/(n-2);
        sum%=(n-2);
    }
    if(sum==0&&sum2<=(n-2))cout<<ans<<endl;
    else cout<<-1<<endl;
}
0