結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 AC 59 ms
4,932 KB
testcase_05 AC 60 ms
4,872 KB
testcase_06 AC 60 ms
5,176 KB
testcase_07 AC 60 ms
4,952 KB
testcase_08 AC 60 ms
4,884 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 61 ms
4,996 KB
testcase_11 AC 61 ms
4,988 KB
testcase_12 AC 60 ms
4,956 KB
testcase_13 AC 59 ms
4,912 KB
testcase_14 AC 59 ms
4,932 KB
testcase_15 AC 60 ms
4,948 KB
testcase_16 AC 60 ms
5,080 KB
testcase_17 AC 60 ms
4,940 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 66 ms
5,172 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 51 ms
4,900 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 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(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