結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2020-07-23 00:24:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,110 bytes |
コンパイル時間 | 1,535 ms |
コンパイル使用メモリ | 166,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 02:54:02 |
合計ジャッジ時間 | 2,981 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<ll, ll> P;const ll MOD = 1e9+7;const ll INF = 1e18;#define rep(i,m,n) for(ll i = (m); i <= (n); i++)#define zep(i,m,n) for(ll i = (m); i < (n); i++)#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)#define print(x) cout << (x) << endl;#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;int main(){cin.tie(0); ios::sync_with_stdio(false);ll n; cin >> n;ll a[n]; zep(i, 0, n)cin >> a[i];ll b[n]; zep(i, 0, n)cin >> b[i];if(n == 2){if(a[0] + a[1] == b[0] + b[1]){print(abs(a[0] - b[0]))}else{print(-1)}return 0;}ll sm = 0;zep(i, 0, n){sm += a[i] - b[i];}if(sm < 0 || sm % (n - 2) != 0){print(-1) return 0;}ll x = sm / (n - 2);ll cnt = 0;zep(i, 0, n){ll y = x - (a[i] - b[i]);if(y % 2 != 0){print(-1) return 0;}cnt += y / 2;}if(cnt == x){print(x)}else{print(-1)}return 0;}