結果

問題 No.116 門松列(1)
ユーザー kcm1700
提出日時 2015-01-04 23:31:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 481 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 36,700 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 00:55:36
合計ジャッジ時間 967 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d",&dat[i]);
      |     ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <algorithm>

using namespace std;

int n;
int dat[100];

int main()
{
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    scanf("%d",&dat[i]);
  }
  int ans = 0;
  for (int i = 0; i+2 < n; i++) {
    int arr[3] = {dat[i],dat[i+1],dat[i+2]};
    sort(arr,arr+3);
    if (arr[1] == dat[i] || arr[1] == dat[i+2]) {
      if (arr[0] != arr[1] && arr[0] != arr[2] && arr[1] != arr[2]) {
        ans ++;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}
0