結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-22 20:59:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 363 bytes |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 57,204 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-09 10:00:38 |
| 合計ジャッジ時間 | 1,014 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | cout << ans << endl;
| ^~~
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int n, x, y, ans;
cin >> n;
for(int i=0; i<n; i++){
cin >> x >> y;
if((i and y - x != ans) or y - x < 1){
cout << -1 << endl;
return 0;
}
ans = y - x;
}
cout << ans << endl;
return 0;
}