結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-02-21 23:11:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 481 bytes |
| コンパイル時間 | 201 ms |
| コンパイル使用メモリ | 34,932 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 00:59:49 |
| 合計ジャッジ時間 | 920 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d", A+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
int main(){
int N;
scanf("%d", &N);
int A[100];
for(int i=0;i<N;i++){
scanf("%d", A+i);
}
int res = 0;
for(int i=0;i+3<=N;i++){
if(A[i] == A[i+1] || A[i] == A[i+2] || A[i+1] == A[i+2]){continue;}
int mid = A[i] + A[i+1] + A[i+2] - std::max({A[i], A[i+1], A[i+2]}) - std::min({A[i], A[i+1], A[i+2]});
if(A[i] == mid || A[i+2] == mid){res += 1;}
}
printf("%d\n", res);
}
tottoripaper