結果
問題 | No.127 門松もどき |
ユーザー | tubo28 |
提出日時 | 2015-01-15 15:43:09 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,732 bytes |
コンパイル時間 | 533 ms |
コンパイル使用メモリ | 67,100 KB |
実行使用メモリ | 74,168 KB |
最終ジャッジ日時 | 2023-09-04 13:07:11 |
合計ジャッジ時間 | 4,125 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,588 KB |
testcase_01 | AC | 2 ms
5,408 KB |
testcase_02 | AC | 2 ms
5,444 KB |
testcase_03 | AC | 2 ms
5,384 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
5,380 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,848 KB |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
5,484 KB |
testcase_10 | AC | 2 ms
5,540 KB |
testcase_11 | AC | 3 ms
8,096 KB |
testcase_12 | AC | 136 ms
55,368 KB |
testcase_13 | AC | 180 ms
62,848 KB |
testcase_14 | AC | 170 ms
60,976 KB |
testcase_15 | AC | 238 ms
70,908 KB |
testcase_16 | AC | 158 ms
59,812 KB |
testcase_17 | AC | 159 ms
63,520 KB |
testcase_18 | AC | 138 ms
58,640 KB |
testcase_19 | AC | 83 ms
43,720 KB |
testcase_20 | AC | 82 ms
46,480 KB |
testcase_21 | AC | 41 ms
25,480 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <cstring> #include <ctime> #include <string> #include <vector> #include <algorithm> #include <cmath> #include <sstream> #include <utility> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i<ll(b); i++) #define rep(i,b) loop(i,0,b) #define each(e,c) for(auto&e:c) #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define lb lower_bound #define ub upper_bound #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl) struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}}; #else #define dump(...) #endif template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" "); return os; } int N; int A[100010]; int dp1[3010][3010]; int dp2[3010][3010]; int rec1(int,int); int rec2(int,int); int rec1(int l, int r){ int & res = dp1[l][r]; if(res!=-1) return res; if(l==r) return res = 1; if(A[l] < A[r]) return res = max(rec1(l,r-1), rec2(l+1,r)+1); return res = rec1(l,r-1); } int rec2(int l, int r){ int & res = dp2[l][r]; if(res!=-1) return res; if(l==r) return res = 1; if(A[r] < A[l]) return res = max(rec2(l+1,r), rec1(l,r-1)+1); return res = rec2(l+1,r); } int main(){ while(cin>>N && N){ rep(i,N) cin >> A[i]; rep(i,N)rep(j,N) dp1[i][j] = dp2[i][j] = -1; cout << max(rec1(0,N-1),rec2(0,N-1)) << endl; } }