結果
問題 | No.1120 Strange Teacher |
ユーザー |
|
提出日時 | 2020-07-23 05:33:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,204 bytes |
コンパイル時間 | 1,636 ms |
コンパイル使用メモリ | 172,516 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 11:02:01 |
合計ジャッジ時間 | 3,940 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 12 |
ソースコード
#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; }