結果

問題 No.1120 Strange Teacher
ユーザー kaede2020kaede2020
提出日時 2020-07-23 07:53:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 166,920 KB
実行使用メモリ 4,952 KB
最終ジャッジ日時 2023-09-05 20:04:30
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 KB
testcase_10 AC 61 ms
4,640 KB
testcase_11 AC 61 ms
4,668 KB
testcase_12 AC 60 ms
4,572 KB
testcase_13 AC 59 ms
4,588 KB
testcase_14 AC 59 ms
4,712 KB
testcase_15 AC 60 ms
4,572 KB
testcase_16 AC 60 ms
4,624 KB
testcase_17 AC 59 ms
4,744 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin>>n;
  long long wa_a=0;
  long long wa_b=0;
  long long sa=-1*LLONG_MAX;
  vector<long long >a(n),b(n);
  long long kotae=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    wa_a+=a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    wa_b+=b[i];
  }
  for(int i=0;i<n;i++){
    sa=max(sa,b[i]-a[i]);
  }
  if(n==2){
    if(wa_a-wa_b==0){
      cout<<sa<<endl;
      return 0;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }else if(n==3){
    if((wa_a-wa_b)%3==0&&sa>0){
      cout<<wa_a-wa_b<<endl;
      return 0;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }else if(sa*(n-2)<= wa_a-wa_b&&(wa_a-wa_b)%(n-2)==0&&sa>0){
    kotae=(wa_a-wa_b)/(n-2);
    cout<<kotae<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}
0