結果

問題 No.1120 Strange Teacher
ユーザー definedefine
提出日時 2020-07-22 21:30:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 933 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 197,612 KB
実行使用メモリ 5,184 KB
最終ジャッジ日時 2023-09-04 15:30:11
合計ジャッジ時間 4,484 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,380 KB
testcase_04 AC 59 ms
5,180 KB
testcase_05 AC 60 ms
4,952 KB
testcase_06 AC 60 ms
4,888 KB
testcase_07 AC 60 ms
4,904 KB
testcase_08 AC 59 ms
5,184 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 60 ms
4,888 KB
testcase_11 AC 61 ms
4,964 KB
testcase_12 AC 62 ms
4,952 KB
testcase_13 AC 60 ms
4,892 KB
testcase_14 AC 60 ms
4,964 KB
testcase_15 AC 60 ms
5,076 KB
testcase_16 AC 62 ms
4,904 KB
testcase_17 AC 60 ms
4,960 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 67 ms
5,060 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 50 ms
4,948 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,A[100005],B[100005];
signed main(){
	cin>>N;
	int sum1=0,sum2=0;
	rep(i,N){
		cin>>A[i];sum1+=A[i];
	}
	int mx=0;
	rep(i,N){
		cin>>B[i];sum2+=B[i];
		chmax(mx,abs(B[i]-A[i]));
	}
	if(N==2){
		if(sum1==sum2)cout<<mx<<endl;
		else cout<<"-1\n";
		return 0;
	}
	if(sum1<sum2)cout<<"-1"<<endl;
	else if((sum1-sum2)%(N-2))cout<<"-1\n";
	else if((sum1-sum2)/(N-2)<mx)cout<<"-1\n";
	else cout<<(sum1-sum2)/(N-2)<<endl;
}
0