結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:10:13: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘long int *’ [-Wformat=]
   10 |     scanf("%d %d",&x[i],&y[i]);
      |            ~^     ~~~~~
      |             |     |
      |             int * long int *
      |            %ld
main.c:10:16: warning: format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘long int *’ [-Wformat=]
   10 |     scanf("%d %d",&x[i],&y[i]);
      |               ~^        ~~~~~
      |                |        |
      |                int *    long int *
      |               %ld
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:21:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   21 |   printf("%d\n",difference[0]);
      |           ~^    ~~~~~~~~~~~~~
      |            |              |
      |            int            long int
      |           %ld
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("%d %d",&x[i],&y[i]);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

  for(i=0;i<n;i++){
    scanf("%d %d",&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("%d\n",difference[0]);
  return 0;
}

0