QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700714 | #4629. Longest Increasing Subsequence | qojszt | AC ✓ | 19ms | 58056kb | C++14 | 1.0kb | 2024-11-02 13:19:31 | 2024-11-02 13:20:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100010], f[100010][70];
int main(){
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; ++i)cin >> a[i];
fill_n(f[1], 70, 1);
for (int i = 2; i <= n; ++i){
long long ds = a[i] - a[i - 1];int dp = __lg(ds);
if (dp == 0)f[i][0] = f[i - 1][0] + 1;
else {
for (int j = 0; j < dp; ++j)f[i][j] = f[i - 1][j] + (1ll << j);
long long Rst = ds - (1ll << dp), lst = 1ll << dp - 1;
//cnt of nodes in last storey(must not full,maybe 0),cnt of nodes in last full storey
f[i][dp] = max(f[i - 1][dp] + Rst, f[i - 1][dp - 1] + max(Rst, lst) + !!Rst);
}
for (int j = dp + 1; j <= 62; ++j)f[i][j] = max(f[i][j], f[i - 1][j]);
for (int j = 1; j <= 62; ++j)f[i][j] = max(f[i][j], f[i][j - 1]);
}
cout << f[n][62] << endl;
return 0;
}
/*
3
1 5 20
11
7
2 3 6 14 15 21 28
13
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5740kb
input:
7 7 41 53 58 75 78 81
output:
22
result:
ok single line: '22'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
8 174 223 259 368 618 738 893 1810
output:
671
result:
ok single line: '671'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5772kb
input:
62 145 189 225 631 638 643 880 1349 1399 1574 1655 1713 1714 2383 2496 2706 2787 2904 2985 3030 3050 3318 3461 3466 3500 3908 3945 4287 4379 4412 4579 4612 4630 4722 4781 4811 4858 4998 5098 5276 6181 6185 6412 6427 6464 6498 6548 6887 6917 7344 7532 7776 8347 8711 8928 8983 9269 9486 9517 9833 9855...
output:
2506
result:
ok single line: '2506'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
88 682 1542 2371 3402 5534 5587 7551 7837 8115 8420 8454 10265 12203 13354 14558 16443 16736 17324 17392 18981 22237 23902 24464 25309 26212 26253 27476 30809 32134 32566 32849 34823 35328 35390 35854 35927 35990 38817 38994 39401 39538 40551 41828 42329 42797 44736 49297 52129 52636 53241 53982 586...
output:
26799
result:
ok single line: '26799'
Test #5:
score: 0
Accepted
time: 1ms
memory: 6040kb
input:
572 24 394 464 487 741 811 1051 1168 1433 1513 1551 1639 1685 1698 1740 1907 2054 2070 2437 2604 2720 3013 3075 3173 3241 3628 3753 4123 4222 4368 4411 4588 4920 5720 5776 5819 5854 6425 6448 6669 6920 7009 7271 7401 7662 7663 8105 8257 8414 8439 8852 8983 9253 9433 9495 9617 9744 9793 9916 10472 10...
output:
25026
result:
ok single line: '25026'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
510 7613 7941 9698 12889 14330 14616 17027 22607 22788 26651 27092 28468 29067 31402 39819 41016 41243 52443 53161 53922 56126 66280 67121 72058 74960 76054 78045 78846 82131 82803 83705 86924 89644 90248 96173 96254 96449 104403 104576 107259 109898 110394 115976 117077 120346 123220 124678 124935 ...
output:
236620
result:
ok single line: '236620'
Test #7:
score: 0
Accepted
time: 0ms
memory: 8988kb
input:
9467 459 1670 1900 2977 4339 4824 7546 8996 9910 10014 11132 11270 11876 13176 13907 14235 14639 14644 15663 16031 16356 17025 17604 20184 20303 20659 22695 25734 26429 27163 27494 28103 28315 28642 29049 30611 30912 31204 35112 38485 38693 38819 39020 39856 40321 40507 41188 41456 41543 42569 43066...
output:
2366515
result:
ok single line: '2366515'
Test #8:
score: 0
Accepted
time: 2ms
memory: 6500kb
input:
5187 11371 81419 105299 108050 231495 240521 268631 278713 298294 336540 342336 353158 375299 412675 419605 435544 452566 480344 493285 518898 536360 548579 563170 579837 589116 603288 612545 619679 657372 676326 729118 742892 745265 745656 760690 801264 816179 829038 841628 842124 884009 909999 912...
output:
24676530
result:
ok single line: '24676530'
Test #9:
score: 0
Accepted
time: 12ms
memory: 41868kb
input:
66119 14804 42108 55330 67931 102798 108875 119215 149954 180393 218546 235989 243788 244433 244527 245202 253953 283116 287175 296124 332731 339822 343675 374501 398197 404997 429858 436650 474806 481168 488274 500469 531545 536181 559683 572503 597408 606812 610579 617146 636507 643239 657864 6685...
output:
244271437
result:
ok single line: '244271437'
Test #10:
score: 0
Accepted
time: 19ms
memory: 51672kb
input:
84013 28467 65863 115524 229455 327923 362190 530953 553094 589745 644905 895339 896428 968983 1120249 1295369 1510596 1559425 1625846 1666339 1692723 1736453 1837504 1921706 2057293 2081395 2135758 2767358 2926638 2968642 3150978 3198214 3206395 3245533 3328817 3369652 3487082 3493724 3508622 36613...
output:
2441739091
result:
ok single line: '2441739091'
Test #11:
score: 0
Accepted
time: 11ms
memory: 34656kb
input:
55848 262408 1159900 2666905 5355707 9557888 15265564 16358799 19501481 22587626 22965044 27522718 30261888 31029633 31097976 33133123 33782771 37826388 37909080 41482560 42753840 42992506 45549679 46704264 46883492 47188058 47352868 48005719 49244954 49459807 50672048 53126468 53596907 56237528 590...
output:
24716495785
result:
ok single line: '24716495785'
Test #12:
score: 0
Accepted
time: 15ms
memory: 58056kb
input:
94504 1093953 2507066 23795154 25855883 28447300 55038876 61868840 64517009 75931003 91174139 110246215 118181145 126734716 134791244 140731049 144090207 148939205 154284762 167157447 170028112 174819319 176664865 202061205 205072733 219897105 228879970 246246886 251398863 263340510 268742442 275257...
output:
247160952145
result:
ok single line: '247160952145'
Test #13:
score: 0
Accepted
time: 12ms
memory: 46404kb
input:
76982 14476501276935 40866525949868 66555792410468 69507797922882 106458420792387 110338205221337 113336076813949 117869582468158 130615980003958 141529043435293 146117123162115 150895009736134 194825823350671 218631219579044 224659299340674 232612532608952 247899161437231 248986641631227 2495988618...
output:
250375725659674641
result:
ok single line: '250375725659674641'