結果

問題 No.1120 Strange Teacher
ユーザー tnakao0123tnakao0123
提出日時 2020-07-24 14:35:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,082 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 91,936 KB
実行使用メモリ 4,444 KB
最終ジャッジ日時 2023-09-07 08:30:57
合計ジャッジ時間 2,799 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 23 ms
4,376 KB
testcase_05 AC 24 ms
4,376 KB
testcase_06 AC 24 ms
4,380 KB
testcase_07 AC 24 ms
4,380 KB
testcase_08 AC 24 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 24 ms
4,380 KB
testcase_11 AC 25 ms
4,376 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 24 ms
4,376 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 25 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 5 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1120.cc:  No.1120 Strange Teacher - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], bs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  ll asum = 0, bsum = 0, psum = 0;
  for (int i = 0; i < n; i++)
    scanf("%d", as + i), asum += as[i];
  for (int i = 0; i < n; i++) {
    scanf("%d", bs + i), bsum += bs[i];
    if (as[i] < bs[i]) psum += bs[i] - as[i];
  }

  int d = n - 2;
  ll f = asum - bsum;
  //printf("d=%d, f=%lld\n", d, f);

  if (d == 0)
    printf("%lld\n", (f == 0) ? psum : -1LL);
  else
    printf("%lld\n", (f >= 0 && f % d == 0 && psum <= f / d) ? f / d : -1LL);
  return 0;
}
0