結果

問題 No.1120 Strange Teacher
ユーザー kaede2020kaede2020
提出日時 2020-07-23 07:32:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 167,376 KB
実行使用メモリ 4,924 KB
最終ジャッジ日時 2023-09-05 19:38:37
合計ジャッジ時間 4,882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 59 ms
4,560 KB
testcase_05 AC 60 ms
4,624 KB
testcase_06 AC 59 ms
4,716 KB
testcase_07 AC 59 ms
4,572 KB
testcase_08 AC 60 ms
4,672 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 61 ms
4,572 KB
testcase_11 AC 60 ms
4,604 KB
testcase_12 AC 60 ms
4,740 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 65 ms
4,520 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 51 ms
4,624 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 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=0;
  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;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }else if(sa*(n-2)<= wa_a-wa_b){
    kotae=(wa_a-wa_b)/(n-2);
    cout<<kotae<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}
0