結果
問題 | No.1120 Strange Teacher |
ユーザー |
|
提出日時 | 2020-07-23 05:18:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,103 bytes |
コンパイル時間 | 1,739 ms |
コンパイル使用メモリ | 174,132 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 10:35:30 |
合計ジャッジ時間 | 4,010 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 8 |
ソースコード
#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);int sa=0;for(int i=0;i<N;i++){cin>>A[i];sa+=A[i];}int sb=0;for(int i=0;i<N;i++){cin>>B[i];sb+=B[i];}if(N>=3&&sa>=sb&&(sa-sb)%(N-2)==0){int t=(sa-sb)/(N-2);bool ok=true;for(int i=0;i<N;i++){int 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&&sa==sb){cout<<A[0]-B[0]<<endl;}else{cout<<-1<<endl;}return 0;}