結果

問題 No.116 門松列(1)
ユーザー tsukacchantsukacchan
提出日時 2016-03-29 19:21:23
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 344 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 20,608 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 01:15:27
合計ジャッジ時間 949 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 | scanf("%d",&N);
      | ^~~~~~~~~~~~~~
main.c:11:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 | scanf("%d",&A[i]);
      | ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(void){

int i, N, A[100];
int counter=0;

scanf("%d",&N);

for(i=0;i<N;i++)
scanf("%d",&A[i]);

for(i=0;i<N-2;i++){
    
if( (A[i]!=A[i+1] && A[i+1]!=A[i+2] && A[i+2]!=A[i]) ) {
counter++;
if(((A[i]<A[i+1]) && (A[i+1]<A[i+2])) ||((A[i]>A[i+1]) && (A[i+1]>A[i+2])))
counter--;
}
}

printf("%d",counter);

return 0;

}
0