結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-25 22:25:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 367 bytes |
| コンパイル時間 | 1,479 ms |
| コンパイル使用メモリ | 167,392 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 02:16:17 |
| 合計ジャッジ時間 | 1,978 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 1 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
21 | cout << ans << endl;
| ^~~
main.cpp:8:21: note: 'ans' was declared here
8 | int a,b,pre,ans; cin>>a>>b;
| ^~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main(){
int n; cin>>n;
int a,b,pre,ans; cin>>a>>b;
pre=b-a;
rep(i,n){
cin>>a>>b;
ans=b-a;
if(pre!=ans){
cout << "-1" << endl;
return 0;
} else if(pre<0||ans<0){
cout << "-1" << endl;
return 0;
}
}
cout << ans << endl;
}