結果

問題 No.284 門松と魔法(2)
ユーザー snukesnuke
提出日時 2015-09-18 23:09:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,836 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 4,772 KB
最終ジャッジ日時 2023-09-26 12:43:43
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 18 ms
4,492 KB
testcase_34 AC 19 ms
4,548 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 27 ms
4,616 KB
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}

const int MX = 100005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;

int n;
int a[MX];
int dl[MX];
int dr[MX];

int solve() {
  rep(i,n) dl[i] = INF;
  dl[0] = -INF;
  rep(i,n) dr[i] = INF;
  rep(i,n) {
    int l = lower_bound(dl,dl+n,a[i])-dl;
    int r = lower_bound(dr,dr+n,-a[i])-dr;
    // cout<<l<<" "<<r<<endl;
    mins(dr[l-1],-a[i]);
    mins(dl[r],a[i]);
  }
  int res = 0;
  rep(i,n) if (dl[i] != INF) maxs(res,i*2);
  rep(i,n) if (dr[i] != INF) maxs(res,i*2+1);
  return res;
}

int main() {
  scanf("%d",&n);
  rep(i,n) scanf("%d",&a[i]);
  int ans = solve();
  rep(i,n) a[i] = -a[i];
  maxs(ans,solve());
  if (ans < 3) ans = 0;
  cout<<ans<<endl;
  return 0;
}




0