結果

問題 No.185 和風
ユーザー ぺ
提出日時 2017-06-15 18:25:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 271 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 21,960 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 07:01:15
合計ジャッジ時間 1,370 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d%d%d",&n,&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d%d",&x,&y);
      |                 ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main()
{
	int n,x,y,z,f,i;
	
	scanf("%d%d%d",&n,&x,&y);
	z=y-x;
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
			if((y-x)!=z){
				f=1;
				break;
			}
	}
	if(f==1){
		puts("-1");
	}else if(z<0){
		puts("-1");
	}else{
		printf("%d\n",z);
	}
	return 0;
}
0