結果
問題 | No.185 和風 |
ユーザー |
![]() |
提出日時 | 2015-04-19 23:28:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 316 bytes |
コンパイル時間 | 103 ms |
コンパイル使用メモリ | 23,936 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 18:22:52 |
合計ジャッジ時間 | 510 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n;scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d%d",&a,&b);c=b-a; | ~~~~~^~~~~~~~~~~~~~ main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d",&a,&b); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){int n;scanf("%d",&n);int a,b,c;scanf("%d%d",&a,&b);c=b-a;for(int i=1;i<n;i++){scanf("%d%d",&a,&b);if(c!=b-a){printf("-1\n");return 0;}}if(c<1)printf("-1\n");else printf("%d\n",c);return 0;}