結果

問題 No.185 和風
ユーザー Shawn stayCShawn stayC
提出日時 2020-05-25 22:27:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 369 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 163,076 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 03:54:50
合計ジャッジ時間 2,040 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
      |                     ^~~

ソースコード

diff #

#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;	
}
0