結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
![]() |
提出日時 | 2020-07-23 21:01:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 2,013 ms |
コンパイル使用メモリ | 195,844 KB |
最終ジャッジ日時 | 2025-01-12 04:31:58 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
ソースコード
#include <bits/stdc++.h> #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef pair<P,P> PP; typedef vector<vector<ll> > Graph; 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 ll INF = 1e18; int main(){ int n; cin >> n; vector<ll>a(n),b(n); ll sa=0,sb=0; rep(i,n){ cin>>a[i]; sa+=a[i]; } rep(i,n){ cin>>b[i]; sb+=b[i]; } if(sa<sb){ cout << -1 << endl; return 0; } if(n==2){ if((sa+sb)%2==0){ cout << abs(a[0]-b[0]) << endl; return 0; } else{ cout << -1 << endl; return 0; } } if((sa-sb)%(n-2)!=0){ cout << -1 << endl; return 0; } ll c = (sa-sb)/(n-2); rep(i,n){ ll ci = a[i]-b[i]+c; if(ci<0||ci%2==1){ cout << -1 << endl; return 0; } } cout << c << endl; return 0; }