結果

問題 No.1120 Strange Teacher
ユーザー kaede2020kaede2020
提出日時 2020-07-22 21:40:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 1,736 ms
コンパイル使用メモリ 166,796 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-09-04 16:35:40
合計ジャッジ時間 3,801 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 2 ms
4,376 KB
testcase_10 AC 61 ms
4,840 KB
testcase_11 AC 61 ms
4,524 KB
testcase_12 AC 61 ms
4,580 KB
testcase_13 AC 59 ms
4,708 KB
testcase_14 AC 60 ms
4,704 KB
testcase_15 AC 60 ms
4,768 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 66 ms
4,628 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int n;
  cin>>n;
  long long sa_tasu=0;
  long long sa_hiku=0;
  vector<long long >a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    long long x=b[i]-a[i];
    if(x>0)sa_tasu+=x;
    else sa_hiku+=x;
  }
  long long kotae=0;
  kotae+=sa_tasu;
  sa_hiku*=-1;
  if(sa_tasu*(n-1)> sa_hiku){
    cout<<-1<<endl;
    return 0;
  }
  sa_hiku-=sa_tasu*(n-1);
  long long nokori=sa_hiku/n*2;
  if(sa_hiku%n==0){
    kotae+=nokori;
    cout<<kotae<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}
0