結果
問題 | No.116 門松列(1) |
ユーザー |
|
提出日時 | 2018-03-26 01:15:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 2,604 bytes |
コンパイル時間 | 1,042 ms |
コンパイル使用メモリ | 110,356 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 01:39:01 |
合計ジャッジ時間 | 1,862 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES#include<iostream>#include<string>#include<cmath>#include<queue>#include<map>#include<set>#include<list>#include<iomanip>#include<vector>#include<random>#include<functional>#include<algorithm>#include<cstdio>#include<bitset>#include<unordered_map>using namespace std;//---------------------------------------------------//ライブラリゾーン!!!!typedef long long ll;typedef long double ld;#define str string#define rep(i,j) for(ll i=0;i<(long long)(j);i++)const ll Mod = 1000000007;const ll gosenchou = 5000000000000000;short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };struct P {ll pos, cost;};bool operator<(P a, P b) { return a.cost < b.cost; }bool operator>(P a, P b) { return a.cost > b.cost; }struct B {//隣接リスト表現ll to;ld cost;};struct E {//辺の情報を入れる変数ll from, to, cost;};bool operator<(E a, E b) {return a.cost < b.cost;}struct H {ll x, y;};bool operator<(H a, H b) {/*if (a.x != b.x) return a.x < b.x;return a.y < b.y;*/return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));}bool operator>(H a, H b) {if (a.x != b.x) return a.x > b.x;return a.y > b.y;}bool operator==(H a, H b) {return a.x == b.x&&a.y == b.y;}bool operator!=(H a, H b) {return a.x != b.x || a.y != b.y;}ll gcm(ll i, ll j) {//最大公約数if (i > j) swap(i, j);if (i == 0) return j;return gcm(j%i, i);}ld rad(H a, H b) {return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));}//rad=座標上の2点間の距離ll ari(ll a, ll b, ll c) {return (a + b)*c / 2;}//等差数列の和ll fact(ll x, ll k, ll p) {//最大値、個数ll sum = 1;for (int i = 0; i < k; i++) {sum *= (x--);sum %= p;}return sum;}//階乗(正)ll mod_pow(ll x, ll n, ll p) {ll res = 1;while (n > 0) {if (n & 1) res = res*x%p;x = x*x%p;n >>= 1;}return res;}//x^n%pint ctoi(char a) {return (int)a - '0';}//#define int long longconst long long Inf = 4523372036854775807;const int inf = 1500000000;//----------------------------------------------------//++++++++++++++++++++++++++++++++++++++++++++++++++++int a[100];signed main() {int n;cin >> n;for (int i = 0; i < n; i++) {cin >> a[i];}int sum = 0;for (int i = 0; i < n - 2; i++) {if (((a[i] > a[i + 1] && a[i] < a[i + 2]) || (a[i] > a[i + 2] && a[i] < a[i + 1]) ||(a[i + 2] > a[i + 1] && a[i + 2] < a[i]) || (a[i + 2] > a[i] && a[i + 2] < a[i + 1])) &&a[i] != a[i + 1] && a[i + 1] != a[i + 2] && a[i] != a[i + 2]) {sum++;}}cout << sum << endl;getchar(); getchar();}