Submission #2049779
Source Code Expand
Copy
#include<bits/stdc++.h> using namespace std; #define MAX 123456 struct BIT{ int t[MAX]; void init(){ for(int i=0;i<MAX;i++){ t[i]=-1000000000; } } int maxm(int i=123450){ int res=-1000000000; i+=5; while(i>0){ res=max(res,t[i]); i-=(i&-i); } return res; } void update(int i,int x){ i+=5; while(i<MAX){ t[i]=max(t[i],x); i+=(i&-i); } } }; BIT A[101]; int N,K; int v[MAX]; vector<int> X; void solve(){ for(int i=0;i<N;i++){ for(int j=0;j<=K;j++){ int tmp=-1; if(j>0){ tmp = A[j-1].maxm(); A[j].update( v[i] , tmp+1); } int cost=-2; cost = A[j].maxm( v[i]-1 ); if(i==0)cost=0; A[j].update( v[i], cost+1); // cout<<max(tmp,cost+1)<<' '; } // cout<<endl; } int ans=1; for(int i=0;i<=100;i++){ ans=max(ans, A[i].maxm() ); } cout<<ans<<endl; } int main(){ cin>>N>>K; for(int i=0;i<N;i++){ cin>>v[i]; X.push_back(v[i]); } sort(X.begin(),X.end()); X.erase( unique( X.begin(), X.end() ) , X.end() ); for(int i=0;i<N;i++){ v[i]=lower_bound( X.begin(),X.end(),v[i]) - X.begin(); v[i]++; // cout<<v[i]<<' '; } // cout<<endl; solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - だんだん強く |
User | dohatsutsu |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1359 Byte |
Status | WA |
Exec Time | 884 ms |
Memory | 49656 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 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 | 2 ms | 384 KB |
00_sample01 | AC | 1 ms | 256 KB |
00_sample02 | AC | 1 ms | 384 KB |
01_minimal00 | AC | 1 ms | 256 KB |
01_minimal01 | WA | 10 ms | 47488 KB |
01_minimal02 | AC | 1 ms | 256 KB |
01_minimal03 | WA | 11 ms | 47488 KB |
20_small_random00 | AC | 6 ms | 22912 KB |
20_small_random01 | WA | 11 ms | 47488 KB |
20_small_random02 | AC | 5 ms | 18816 KB |
20_small_random03 | WA | 8 ms | 29056 KB |
20_small_random04 | AC | 6 ms | 20864 KB |
20_small_random05 | AC | 6 ms | 20864 KB |
20_small_random06 | AC | 4 ms | 12672 KB |
20_small_random07 | AC | 3 ms | 8576 KB |
20_small_random08 | WA | 8 ms | 31104 KB |
20_small_random09 | WA | 9 ms | 37248 KB |
20_small_random10 | AC | 4 ms | 14720 KB |
20_small_random11 | WA | 8 ms | 33152 KB |
20_small_random12 | WA | 10 ms | 41344 KB |
20_small_random13 | WA | 11 ms | 43392 KB |
20_small_random14 | WA | 8 ms | 31104 KB |
20_small_random15 | AC | 5 ms | 16768 KB |
20_small_random16 | AC | 6 ms | 20864 KB |
20_small_random17 | WA | 7 ms | 27008 KB |
20_small_random18 | AC | 3 ms | 10624 KB |
20_small_random19 | AC | 4 ms | 12672 KB |
21_small_increasing00 | AC | 1 ms | 256 KB |
21_small_increasing01 | WA | 3 ms | 10624 KB |
21_small_increasing02 | WA | 5 ms | 18816 KB |
21_small_increasing03 | WA | 8 ms | 29056 KB |
21_small_increasing04 | WA | 10 ms | 39296 KB |
21_small_increasing05 | WA | 11 ms | 47488 KB |
22_small_decreasing00 | AC | 1 ms | 256 KB |
22_small_decreasing01 | AC | 4 ms | 10624 KB |
22_small_decreasing02 | AC | 5 ms | 18816 KB |
22_small_decreasing03 | AC | 7 ms | 29056 KB |
22_small_decreasing04 | AC | 10 ms | 39296 KB |
22_small_decreasing05 | WA | 12 ms | 47488 KB |
23_small_mountain00 | AC | 1 ms | 256 KB |
23_small_mountain01 | AC | 3 ms | 10624 KB |
23_small_mountain02 | AC | 5 ms | 18816 KB |
23_small_mountain03 | WA | 7 ms | 29056 KB |
23_small_mountain04 | WA | 10 ms | 39296 KB |
23_small_mountain05 | WA | 12 ms | 47488 KB |
24_small_valley00 | AC | 1 ms | 256 KB |
24_small_valley01 | AC | 3 ms | 10624 KB |
24_small_valley02 | AC | 5 ms | 18816 KB |
24_small_valley03 | WA | 8 ms | 29056 KB |
24_small_valley04 | WA | 10 ms | 39296 KB |
24_small_valley05 | WA | 11 ms | 47488 KB |
30_large_random00 | AC | 670 ms | 27000 KB |
30_large_random01 | AC | 317 ms | 16760 KB |
30_large_random02 | AC | 75 ms | 1528 KB |
30_large_random03 | AC | 105 ms | 4472 KB |
30_large_random04 | AC | 371 ms | 20856 KB |
31_large_increasing00 | AC | 62 ms | 1528 KB |
31_large_increasing01 | WA | 434 ms | 27128 KB |
31_large_increasing02 | WA | 853 ms | 49656 KB |
32_large_decreasing00 | AC | 63 ms | 1528 KB |
32_large_decreasing01 | AC | 434 ms | 27128 KB |
32_large_decreasing02 | AC | 862 ms | 49656 KB |
33_large_mountain00 | AC | 68 ms | 1400 KB |
33_large_mountain01 | AC | 453 ms | 26488 KB |
33_large_mountain02 | AC | 884 ms | 49016 KB |
34_large_valley00 | AC | 69 ms | 1400 KB |
34_large_valley01 | AC | 450 ms | 26488 KB |
34_large_valley02 | AC | 884 ms | 49016 KB |