結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-22 21:40:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 610 bytes |
| コンパイル時間 | 1,481 ms |
| コンパイル使用メモリ | 168,456 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 14:46:38 |
| 合計ジャッジ時間 | 3,644 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
long long sa_tasu=0;
long long sa_hiku=0;
vector<long long >a(n),b(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
for(int i=0;i<n;i++){
long long x=b[i]-a[i];
if(x>0)sa_tasu+=x;
else sa_hiku+=x;
}
long long kotae=0;
kotae+=sa_tasu;
sa_hiku*=-1;
if(sa_tasu*(n-1)> sa_hiku){
cout<<-1<<endl;
return 0;
}
sa_hiku-=sa_tasu*(n-1);
long long nokori=sa_hiku/n*2;
if(sa_hiku%n==0){
kotae+=nokori;
cout<<kotae<<endl;
}else{
cout<<-1<<endl;
}
return 0;
}