結果
問題 | No.284 門松と魔法(2) |
ユーザー | snuke |
提出日時 | 2015-09-18 23:17:58 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,126 bytes |
コンパイル時間 | 962 ms |
コンパイル使用メモリ | 85,852 KB |
実行使用メモリ | 20,116 KB |
最終ジャッジ日時 | 2023-09-26 12:45:00 |
合計ジャッジ時間 | 3,236 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
19,652 KB |
testcase_01 | AC | 9 ms
19,456 KB |
testcase_02 | AC | 8 ms
19,500 KB |
testcase_03 | AC | 8 ms
19,468 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 9 ms
19,556 KB |
testcase_10 | AC | 8 ms
19,704 KB |
testcase_11 | AC | 9 ms
19,484 KB |
testcase_12 | AC | 9 ms
19,532 KB |
testcase_13 | AC | 9 ms
19,680 KB |
testcase_14 | WA | - |
testcase_15 | AC | 8 ms
19,552 KB |
testcase_16 | AC | 9 ms
19,512 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 8 ms
19,656 KB |
testcase_20 | AC | 8 ms
19,660 KB |
testcase_21 | AC | 9 ms
19,500 KB |
testcase_22 | AC | 8 ms
19,560 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 8 ms
19,472 KB |
testcase_27 | AC | 9 ms
19,460 KB |
testcase_28 | AC | 9 ms
19,508 KB |
testcase_29 | AC | 100 ms
19,720 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 105 ms
19,764 KB |
testcase_33 | AC | 66 ms
19,820 KB |
testcase_34 | AC | 64 ms
19,852 KB |
testcase_35 | AC | 9 ms
19,452 KB |
testcase_36 | AC | 8 ms
19,552 KB |
testcase_37 | AC | 68 ms
19,940 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
#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 int MY = 1000005; const ll LINF = 1000000000000000000ll; const double eps = 1e-10; int n; int ax[MX]; // Segment tree (RMQ type) struct seg { vector<int> d; int x2; seg(){} seg(int mx){ x2 = 1; while(x2 < mx) x2 <<= 1; d.resize(x2<<1);} void add(int i, int x=0){ for(i+=x2;i;i>>=1) d[i] = max(d[i],x); // update } int get(int a, int b, int i=1, int l=0, int r=-1){ if (r == -1) r = x2; if(a <= l && r <= b) return d[i]; int c = (l+r)>>1; int res = 0; if(a < c) res = max(res,get(a,b,i<<1,l,c)); if(c < b) res = max(res,get(a,b,i<<1|1,c,r)); return res; } }; // int solve() { seg dl(MY), dr(MY); rep(i,n) { int a = ax[i]; int ml = dl.get(0,a); int mr = dr.get(a+1,MY); dl.add(a,mr+1); dr.add(a,ml+1); } return max(dl.get(0,MY),dr.get(0,MY)); } int main() { scanf("%d",&n); rep(i,n) scanf("%d",&ax[i]); int ans = solve(); if (ans < 3) ans = 0; cout<<ans<<endl; return 0; }