結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
|
提出日時 | 2020-07-22 21:37:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 485 bytes |
コンパイル時間 | 1,996 ms |
コンパイル使用メモリ | 194,168 KB |
最終ジャッジ日時 | 2025-01-12 02:20:25 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:12:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | rep(i,n) scanf("%d",&b[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n; scanf("%d",&n); vector<int> a(n),b(n); rep(i,n) scanf("%d",&a[i]); rep(i,n) scanf("%d",&b[i]); lint d=0; rep(i,n) d+=a[i]-b[i]; if(n==2){ puts(d==0?"0":"-1"); return 0; } if(d<0 || d%(n-2)!=0) return puts("-1"),0; lint k=d/(n-2); rep(i,n) if((b[i]-a[i]+k)<0 || (b[i]-a[i]+k)%2!=0) return puts("-1"),0; printf("%lld\n",k); return 0; }