結果
問題 | No.992 最長増加部分列の数え上げ |
ユーザー | heno239 |
提出日時 | 2020-02-15 03:15:36 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,167 bytes |
コンパイル時間 | 1,600 ms |
コンパイル使用メモリ | 130,100 KB |
実行使用メモリ | 22,500 KB |
最終ジャッジ日時 | 2024-04-16 03:05:06 |
合計ジャッジ時間 | 10,828 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 95 ms
11,548 KB |
testcase_05 | AC | 66 ms
8,320 KB |
testcase_06 | AC | 124 ms
12,508 KB |
testcase_07 | AC | 87 ms
11,004 KB |
testcase_08 | AC | 40 ms
7,296 KB |
testcase_09 | AC | 89 ms
11,276 KB |
testcase_10 | AC | 123 ms
12,512 KB |
testcase_11 | AC | 165 ms
13,760 KB |
testcase_12 | AC | 26 ms
5,760 KB |
testcase_13 | AC | 81 ms
11,096 KB |
testcase_14 | AC | 81 ms
10,864 KB |
testcase_15 | AC | 26 ms
5,760 KB |
testcase_16 | AC | 284 ms
21,356 KB |
testcase_17 | AC | 40 ms
7,168 KB |
testcase_18 | AC | 80 ms
10,976 KB |
testcase_19 | AC | 165 ms
13,744 KB |
testcase_20 | AC | 306 ms
22,364 KB |
testcase_21 | AC | 312 ms
22,384 KB |
testcase_22 | AC | 306 ms
22,388 KB |
testcase_23 | AC | 310 ms
22,368 KB |
testcase_24 | AC | 321 ms
22,500 KB |
testcase_25 | AC | 320 ms
22,260 KB |
testcase_26 | AC | 315 ms
22,432 KB |
testcase_27 | AC | 321 ms
22,368 KB |
testcase_28 | AC | 314 ms
22,392 KB |
testcase_29 | AC | 315 ms
22,260 KB |
testcase_30 | AC | 186 ms
21,500 KB |
testcase_31 | AC | 182 ms
21,352 KB |
testcase_32 | AC | 186 ms
21,504 KB |
testcase_33 | AC | 183 ms
21,492 KB |
testcase_34 | AC | 184 ms
21,548 KB |
testcase_35 | AC | 176 ms
21,364 KB |
testcase_36 | AC | 179 ms
21,488 KB |
testcase_37 | AC | 177 ms
21,508 KB |
testcase_38 | AC | 177 ms
21,496 KB |
testcase_39 | AC | 176 ms
21,512 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
ソースコード
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<utility> #include<map> #include<set> #include<bitset> #include<stack> #include<cassert> #include<random> #include<unordered_map> #include<numeric> using namespace std; using ll = long long; const ll mod = 1000000007; const ll INF = (1e+18) + 7; #define rep(i,n) for(int i=0;i<n;i++) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define all(x) (x).begin(),(x).end() #define stop char nyaa;cin>>nyaa; using P = pair<int, int>; using LP = pair<ll, ll>; struct SegT { private: int sz; vector<LP> node; const LP init_c = { 0,0 }; public: SegT(int n) { sz = 1; while (sz < n)sz *= 2; node.resize(2 * sz - 1, init_c); } LP f(LP a, LP b) { if (a.first < b.first)return b; if (a.first > b.first)return a; ll res = a.second + b.second; if (res >= mod)res -= mod; return { a.first,res }; } void update(int k, LP a) { k += sz - 1; if (node[k].first == a.first)node[k].second += a.second; else if (node[k].first<a.first)node[k] = a; while (k > 0) { k = (k - 1) / 2; node[k] = f(node[k * 2 + 1], node[k * 2 + 2]); } } LP query(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0)r = sz; if (r <= a || b <= l)return init_c; else if (a <= l && r <= b)return node[k]; else { LP vl = query(a, b, k * 2 + 1, l, (l + r) / 2); LP vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return f(vl, vr); } } }; void solve() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } vector<int> x; rep(i, n)x.push_back(a[i]); x.push_back(-mod); sort(all(x)); x.erase(unique(all(x)), x.end()); map<int, int> mp; rep(i, x.size())mp[x[i]] = i; rep(i, n)a[i] = mp[a[i]]; SegT st(x.size()); st.update(0,{ 0,1 }); rep(i, n) { LP p = st.query(0, a[i]); p.first++; st.update(a[i], p); } LP ans = st.query(0, x.size()); cout << ans.second << endl; } signed main() { cin.tie(0); ios::sync_with_stdio(false); //int t; cin >> t;rep(i,t) solve(); solve(); stop return 0; }