結果

問題 No.185 和風
ユーザー umashikaumashika
提出日時 2016-02-01 21:20:08
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 388 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 22,024 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 18:33:26
合計ジャッジ時間 654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:18:7: warning: ‘return’ with no value, in function returning non-void
   18 |       return;
      |       ^~~~~~
main.c:2:5: note: declared here
    2 | int main(void){
      |     ^~~~
main.c:5:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~
main.c:10:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%ld %ld",&x[i],&y[i]);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main(void){
  int n;
  int i;
  scanf("%d",&n);
  long int x[n],y[n];
  long int difference[n];

  for(i=0;i<n;i++){
    scanf("%ld %ld",&x[i],&y[i]);
  }
  for(i=0;i<n;i++){
    difference[i]=y[i]-x[i];
  }
  for(i=0;i<n-1;i++){
    if(difference[i]!=difference[i+1]){
      printf("-1\n");
      return;
    }
  }
  printf("%ld\n",difference[0]);
  return 0;
}



0