結果

問題 No.1120 Strange Teacher
ユーザー abc3abc3
提出日時 2020-07-23 05:33:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,204 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 171,556 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 15:29:12
合計ジャッジ時間 4,217 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>A(N),B(N);
  int64_t sa=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sa+=A[i];
  }
  int64_t sb=0;
  for(int i=0;i<N;i++){
    cin>>B[i];
    sb+=B[i];
  }
  if(N>=3){
    if(sb>=sa){cout<<-1<<endl;}
    else if((sa-sb)%(N-2)==0){
      int64_t t=(sa-sb)/(N-2);
      bool ok=true;
      for(int i=0;i<N;i++){
        int64_t q=abs(A[i]-B[i]);
        if(t<q&&(q-t)%2!=0){ok=false;}
      }
    if(ok){cout<<t<<endl;}
    else{cout<<-1<<endl;}
    }
  }
  else if(N==2){
    if(sa==sb){cout<<A[0]-B[0]<<endl;}
    else{cout<<-1<<endl;}
  }
  else{cout<<-1<<endl;}
  return 0;
}
0