結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2020-02-05 04:19:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 550 ms |
コンパイル使用メモリ | 64,972 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 18:00:52 |
合計ジャッジ時間 | 1,222 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream> using namespace std; bool func(int a, int b, int c) { bool ok = true; if (a == b || b == c || c == a) ok = false; int nmax = max(a, max(b, c)), nmin = min(a, min(b, c)); if (b != nmax && b != nmin) ok = false; return ok; } int main(void) { int n, a, b, c, tmp; cin >> n >> a >> b >> c; int ans = 0; if (func(a, b, c)) ++ans; for (int i = 3; i < n; ++i) { cin >> tmp; a = b, b = c, c = tmp; if (func(a, b, c)) ++ans; } cout << ans << endl; return 0; }