結果

問題 No.1120 Strange Teacher
ユーザー bachoppibachoppi
提出日時 2020-07-22 22:23:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,125 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 98,968 KB
実行使用メモリ 5,176 KB
最終ジャッジ日時 2023-09-04 21:28:14
合計ジャッジ時間 4,205 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,380 KB
testcase_10 AC 66 ms
4,916 KB
testcase_11 AC 67 ms
4,964 KB
testcase_12 AC 66 ms
4,940 KB
testcase_13 AC 61 ms
5,040 KB
testcase_14 AC 61 ms
4,968 KB
testcase_15 AC 60 ms
4,944 KB
testcase_16 AC 61 ms
4,960 KB
testcase_17 AC 60 ms
5,052 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 1 ms
4,384 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

  
  
   

int main(){
  int n; cin >> n; int a[n], b[n], sa[n];
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    cin >> b[i];
  }
  int sum = 0;
  rep(i, n){
    sa[i] = a[i]-b[i]; sum+=sa[i];
  }
  bool can = true;
  if(sum%(n-2)!=0) can = false;
  //cout << can << endl;
  rep(i, n-1){
    if(abs(sa[i])%2!=abs(sa[i+1])%2) can=false;
  }
  sort(sa, sa+n, greater<>()); int kai[n]; kai[0] = 0; int k = 0;
  rep(i, n-1){
    kai[i+1] = kai[i]+(sa[i]-sa[i+1])/2; k+=kai[i+1];
  }
  if(k>sum/(n-2)) can=false;
  if(can) cout << "Yes" << endl;
  else cout << -1 << endl;
}
0