結果

問題 No.284 門松と魔法(2)
ユーザー sigma425sigma425
提出日時 2016-09-24 02:58:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 175,576 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 23:02:01
合計ジャッジ時間 4,323 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,632 KB
testcase_01 AC 3 ms
5,632 KB
testcase_02 AC 3 ms
5,632 KB
testcase_03 AC 4 ms
5,760 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
5,504 KB
testcase_10 AC 3 ms
5,632 KB
testcase_11 AC 3 ms
5,632 KB
testcase_12 AC 4 ms
5,632 KB
testcase_13 AC 4 ms
5,760 KB
testcase_14 WA -
testcase_15 AC 4 ms
5,632 KB
testcase_16 AC 3 ms
5,632 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 4 ms
5,632 KB
testcase_20 AC 4 ms
5,504 KB
testcase_21 AC 3 ms
5,632 KB
testcase_22 AC 3 ms
5,504 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
5,760 KB
testcase_27 AC 3 ms
5,632 KB
testcase_28 AC 3 ms
5,760 KB
testcase_29 AC 78 ms
6,356 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 89 ms
6,356 KB
testcase_33 AC 52 ms
6,352 KB
testcase_34 AC 53 ms
6,356 KB
testcase_35 AC 3 ms
5,632 KB
testcase_36 AC 4 ms
5,504 KB
testcase_37 AC 32 ms
6,352 KB
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

struct segtree{
	static const int N=1<<17;
	int seg[N*2];
	segtree(){
		rep(i,N*2) seg[i]=0;
	}
	void update(int x,int v){
		x+=N;
		if(seg[x]>v) return;
		seg[x]=v;
		x/=2;
		while(x){
			seg[x]=max(seg[x*2],seg[x*2+1]);
			x/=2;
		}
	}
	int getmax(int a,int b,int l=0,int r=N,int k=1){
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return seg[k];
		return max(getmax(a,b,l,(l+r)/2,k*2),getmax(a,b,(l+r)/2,r,k*2+1));
	}
}up,down;


int N;
int x[100000];
vector<int> xs;
int main(){
	cin>>N;
	rep(i,N){
		scanf("%d",x+i);
		xs.pb(x[i]);
	}
	sort(all(xs));
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	int K=xs.size();
	rep(i,N) x[i]=lower_bound(all(xs),x[i])-xs.begin();
	int ans=0;
	rep(i,N){
		//go up
		int dmx=down.getmax(0,x[i])+1;
		chmax(ans,dmx);
		up.update(x[i],dmx);
		//go down
		int umx=up.getmax(x[i]+1,K)+1;
		chmax(ans,umx);
		down.update(x[i],umx);
	}
	if(ans<=2) ans=0;
	cout<<ans<<endl;
}
0