Submission #2049758
Source Code Expand
Copy
#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cmath> #include <iomanip> #include <cassert> #include <bitset> using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i=0; i<(n); i++) #define all(c) (c).begin(), (c).end() #define uniq(c) c.erase(unique(all(c)), (c).end()) #define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin()) #define _1 first #define _2 second #define pb push_back #define INF 1145141919 #define MOD 1000000007 #define MAX_N (1<<17) struct SegTree { int seg[MAX_N*2-1] = {}; SegTree() { rep(i, MAX_N*2-1) seg[i] = -INF; } void update(int i, int x) { i += MAX_N-1; seg[i] = max(seg[i], x); while (i > 0) { i = (i-1) / 2; seg[i] = max(seg[i*2+1], seg[i*2+2]); } } int query(int a, int b, int k=0, int l=0, int r=MAX_N) { if (r <= a || b <= l) return 0; if (a <= l && r <= b) return seg[k]; return max( query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r) ); } }; int N, K; int A[100000]; vector<int> xs; SegTree seg[101]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> K; vector<int> xs; xs.pb(-1); rep(i, N) cin >> A[i], xs.pb(A[i]); sort(all(xs)); uniq(xs); rep(i, N) A[i] = index(xs, A[i]); seg[0].update(0, 0); rep(i, N) { int a = A[i]; for (int k=K-1; k>=0; k--) seg[k+1].update(a, seg[k].seg[0]+1); for (int k=K; k>=0; k--) seg[k].update(a, seg[k].query(0, a)+1); } int m = 0; rep(i, K+1) m = max(m, seg[i].seg[0]); cout << m << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - だんだん強く |
User | funcsr |
Language | C++14 (GCC 5.4.1) |
Score | 800 |
Code Size | 1745 Byte |
Status | AC |
Exec Time | 2059 ms |
Memory | 104572 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 800 / 800 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample00, 00_sample01, 00_sample02, 01_minimal00, 01_minimal01, 01_minimal02, 01_minimal03, 20_small_random00, 20_small_random01, 20_small_random02, 20_small_random03, 20_small_random04, 20_small_random05, 20_small_random06, 20_small_random07, 20_small_random08, 20_small_random09, 20_small_random10, 20_small_random11, 20_small_random12, 20_small_random13, 20_small_random14, 20_small_random15, 20_small_random16, 20_small_random17, 20_small_random18, 20_small_random19, 21_small_increasing00, 21_small_increasing01, 21_small_increasing02, 21_small_increasing03, 21_small_increasing04, 21_small_increasing05, 22_small_decreasing00, 22_small_decreasing01, 22_small_decreasing02, 22_small_decreasing03, 22_small_decreasing04, 22_small_decreasing05, 23_small_mountain00, 23_small_mountain01, 23_small_mountain02, 23_small_mountain03, 23_small_mountain04, 23_small_mountain05, 24_small_valley00, 24_small_valley01, 24_small_valley02, 24_small_valley03, 24_small_valley04, 24_small_valley05, 30_large_random00, 30_large_random01, 30_large_random02, 30_large_random03, 30_large_random04, 31_large_increasing00, 31_large_increasing01, 31_large_increasing02, 32_large_decreasing00, 32_large_decreasing01, 32_large_decreasing02, 33_large_mountain00, 33_large_mountain01, 33_large_mountain02, 34_large_valley00, 34_large_valley01, 34_large_valley02 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample00 | AC | 37 ms | 103680 KB |
00_sample01 | AC | 37 ms | 103680 KB |
00_sample02 | AC | 37 ms | 103680 KB |
01_minimal00 | AC | 37 ms | 103680 KB |
01_minimal01 | AC | 37 ms | 103680 KB |
01_minimal02 | AC | 37 ms | 103680 KB |
01_minimal03 | AC | 37 ms | 103680 KB |
20_small_random00 | AC | 38 ms | 103680 KB |
20_small_random01 | AC | 39 ms | 103680 KB |
20_small_random02 | AC | 38 ms | 103680 KB |
20_small_random03 | AC | 38 ms | 103680 KB |
20_small_random04 | AC | 38 ms | 103680 KB |
20_small_random05 | AC | 38 ms | 103680 KB |
20_small_random06 | AC | 37 ms | 103680 KB |
20_small_random07 | AC | 37 ms | 103680 KB |
20_small_random08 | AC | 38 ms | 103680 KB |
20_small_random09 | AC | 39 ms | 103680 KB |
20_small_random10 | AC | 37 ms | 103680 KB |
20_small_random11 | AC | 38 ms | 103680 KB |
20_small_random12 | AC | 39 ms | 103680 KB |
20_small_random13 | AC | 39 ms | 103680 KB |
20_small_random14 | AC | 38 ms | 103680 KB |
20_small_random15 | AC | 37 ms | 103680 KB |
20_small_random16 | AC | 38 ms | 103680 KB |
20_small_random17 | AC | 38 ms | 103680 KB |
20_small_random18 | AC | 37 ms | 103680 KB |
20_small_random19 | AC | 37 ms | 103680 KB |
21_small_increasing00 | AC | 37 ms | 103680 KB |
21_small_increasing01 | AC | 37 ms | 103680 KB |
21_small_increasing02 | AC | 37 ms | 103680 KB |
21_small_increasing03 | AC | 38 ms | 103680 KB |
21_small_increasing04 | AC | 38 ms | 103680 KB |
21_small_increasing05 | AC | 39 ms | 103680 KB |
22_small_decreasing00 | AC | 37 ms | 103680 KB |
22_small_decreasing01 | AC | 37 ms | 103680 KB |
22_small_decreasing02 | AC | 37 ms | 103680 KB |
22_small_decreasing03 | AC | 38 ms | 103680 KB |
22_small_decreasing04 | AC | 38 ms | 103680 KB |
22_small_decreasing05 | AC | 39 ms | 103680 KB |
23_small_mountain00 | AC | 37 ms | 103680 KB |
23_small_mountain01 | AC | 37 ms | 103680 KB |
23_small_mountain02 | AC | 37 ms | 103680 KB |
23_small_mountain03 | AC | 38 ms | 103680 KB |
23_small_mountain04 | AC | 38 ms | 103680 KB |
23_small_mountain05 | AC | 39 ms | 103680 KB |
24_small_valley00 | AC | 37 ms | 103680 KB |
24_small_valley01 | AC | 37 ms | 103680 KB |
24_small_valley02 | AC | 38 ms | 103680 KB |
24_small_valley03 | AC | 38 ms | 103680 KB |
24_small_valley04 | AC | 38 ms | 103680 KB |
24_small_valley05 | AC | 39 ms | 103680 KB |
30_large_random00 | AC | 1317 ms | 104572 KB |
30_large_random01 | AC | 804 ms | 104572 KB |
30_large_random02 | AC | 83 ms | 104572 KB |
30_large_random03 | AC | 158 ms | 104572 KB |
30_large_random04 | AC | 957 ms | 104572 KB |
31_large_increasing00 | AC | 65 ms | 104572 KB |
31_large_increasing01 | AC | 989 ms | 104572 KB |
31_large_increasing02 | AC | 2005 ms | 104572 KB |
32_large_decreasing00 | AC | 66 ms | 104572 KB |
32_large_decreasing01 | AC | 1024 ms | 104572 KB |
32_large_decreasing02 | AC | 2059 ms | 104572 KB |
33_large_mountain00 | AC | 71 ms | 104572 KB |
33_large_mountain01 | AC | 1011 ms | 104572 KB |
33_large_mountain02 | AC | 2036 ms | 104572 KB |
34_large_valley00 | AC | 71 ms | 104572 KB |
34_large_valley01 | AC | 1012 ms | 104572 KB |
34_large_valley02 | AC | 2036 ms | 104572 KB |