結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
re1ns
|
| 提出日時 | 2015-11-06 16:46:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 477 bytes |
| コンパイル時間 | 498 ms |
| コンパイル使用メモリ | 61,572 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 13:04:24 |
| 合計ジャッジ時間 | 970 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
25 | cout << ans << endl;
| ^~~
ソースコード
#include<iostream>
#include<climits>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int n;
int ans;
bool f=true;
cin >> n;
vector<int> x(n),y(n);
for(int i=0;i<n;i++){
cin >> x[i] >> y[i];
ans = y[i]-x[i];
if(ans<0){
ans=-1;
break;
}
if(i!=0&&ans!=y[i-1]-x[i-1]){
ans = -1;
break;
}
}
cout << ans << endl;
}
re1ns