QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303949 | #8006. Dinosaur Bones Digging | ucup-team2303# | TL | 3774ms | 38496kb | C++17 | 2.4kb | 2024-01-13 08:58:19 | 2024-01-13 08:58:20 |
Judging History
answer
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define PB emplace_back
#define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) { rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1]; }
const int N = 1e6;
int a, b, c, p[N + 5], q[N + 5], w[N * 4 + 5], lzy[N * 4 + 5];
struct pii {
int x, y;
} s[N + 5], t[N + 5];
#define ls n << 1
#define rs n << 1 | 1
void upd(int n, int k) {
w[n] += k;
lzy[n] += k;
}
void dw(int n) {
upd(ls, lzy[n]);
upd(rs, lzy[n]);
lzy[n] = 0;
}
void add(int n, int l, int r, int L, int R, int k) {
if(L > R) return;
if(l >= L && r <= R) return upd(n, k), void();
int mid = (l + r) >> 1;
dw(n);
if(L <= mid) add(ls, l, mid, L, R, k);
if(mid < R) add(rs, mid + 1, r, L, R, k);
w[n] = max(w[ls], w[rs]);
}
int ask(int n, int l, int r, int L, int R) {
if(L > R) return 0;
if(l == r) return w[n];
dw(n);
int mid = (l + r) >> 1, res = 0;
if(L <= mid) res = max(res, ask(ls, l, mid, L, R));
if(mid < R) res = max(res, ask(rs, mid + 1, r, L, R));
return res;
}
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> a;
rep(i, 1, a) cin >> p[i], q[i] = i;
cin >> b;
rep(i, 1, b) cin >> s[i].x >> s[i].y;
sort(s + 1, s + b + 1, [&] (pii x, pii y) {
return x.x < y.x || (x.x == y.x && x.y > y.y);
});
int now = 0;
rep(i, 1, b) {
if(s[i].y > now) t[++c] = s[i];
now = max(now, s[i].y);
}
// cout << c << endl;
sort(q + 1, q + a + 1, [&] (int x, int y) {
return p[x] > p[y];
});
int ans = 0;
rep(i, 1, a) {
// cout << ask(1, 1, c, q[i]) * p[q[i]] << endl;
int l = lower_bound(t + 1, t + c + 1, pii {0, q[i]}, [&] (pii x, pii y) {
return x.y < y.y;
}) - t;
int r = upper_bound(t + 1, t + c + 1, pii {q[i], 0}, [&] (pii x, pii y) {
return x.x < y.x;
}) - t;
ans = max(ans, ask(1, 1, c, l, r - 1) * p[q[i]]);
// cout << l << ' ' << r << endl;
add(1, 1, c, l, r - 1, 1);
}
cout << ans;
return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 10044kb
input:
6 3 5 2 7 4 6 2 1 5 3 6
output:
9
result:
ok answer is '9'
Test #2:
score: 0
Accepted
time: 1ms
memory: 9980kb
input:
1 100 1 1 1
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 2ms
memory: 10096kb
input:
20 451541695 690066663 673479208 448269517 560111835 982439295 929007403 955125568 735150915 829197546 256554877 435297385 348361716 763574893 202875223 881879899 590527232 256896900 31383620 400212120 5 4 8 4 17 11 13 19 20 17 18
output:
4480894680
result:
ok answer is '4480894680'
Test #4:
score: 0
Accepted
time: 0ms
memory: 10024kb
input:
100 310791482 148245051 114541081 918781914 681485137 656214017 226939378 970492592 431199764 162399115 490488808 3059986 487892489 611730708 952388887 418021477 917893766 587279310 363995315 342188612 72531000 156997725 896382592 359419647 144773021 872005978 496280920 65840663 56171913 273988049 6...
output:
23457460782
result:
ok answer is '23457460782'
Test #5:
score: 0
Accepted
time: 0ms
memory: 10096kb
input:
1000 653152089 378327983 557774751 390757038 4471201 856292034 205122039 30258841 396640873 159207453 703775065 793745674 681241216 876218560 582247644 205933914 957242345 112988670 939157518 525653622 262606938 993539583 451620719 700727137 142726078 430071359 426031860 471766448 94089907 167433741...
output:
242077104830
result:
ok answer is '242077104830'
Test #6:
score: 0
Accepted
time: 5ms
memory: 12032kb
input:
10000 760845880 236665988 765352292 817854026 789863420 399953246 270535243 932350041 48814223 670950468 456660682 416165008 999681497 666880584 56581573 134567049 403285848 144814129 973325555 23519957 518449311 738687225 345716065 2309498 477743569 555951695 911860717 920761968 569179690 349857557...
output:
2452630249040
result:
ok answer is '2452630249040'
Test #7:
score: 0
Accepted
time: 199ms
memory: 26452kb
input:
75000 64097076 228795807 236402963 795983877 911904460 793466611 195874572 123239434 599032119 741932 916254858 335612220 445268867 659313703 848780671 12116264 105543333 438293575 879273474 875134498 618135541 308227823 220867277 683811264 720576432 874505737 896095678 437505375 945318773 658945922...
output:
18740230889380
result:
ok answer is '18740230889380'
Test #8:
score: 0
Accepted
time: 191ms
memory: 28448kb
input:
100000 237252794 382693085 295147362 674980341 2958154 807156999 970437955 781426294 772360469 332498984 366981282 102374212 992836938 434644540 742598545 821844749 65037055 208304069 38844999 893543237 392739243 968841288 483750814 102524579 991416234 875749582 237552019 633704354 706506941 8051497...
output:
24967271468601
result:
ok answer is '24967271468601'
Test #9:
score: 0
Accepted
time: 36ms
memory: 10084kb
input:
100000 38413036 456923902 821971466 586909482 636298728 158178471 84422915 632002470 34405999 882453211 922025994 294603996 207311349 526030511 417456448 362917277 456078308 435018316 47342069 47738636 642863127 189926256 40263985 58857249 119358305 864464366 83617839 485428518 305918980 942395945 6...
output:
24903646283538
result:
ok answer is '24903646283538'
Test #10:
score: 0
Accepted
time: 81ms
memory: 14196kb
input:
193531 700185685 653403475 398038439 272114589 644859446 234924539 412364196 347296552 436428000 711722981 547258844 794359236 961133698 639407426 480555752 954373403 653187777 339413210 11632662 145811119 988611894 708168836 83399147 696410193 214277102 445328303 392328860 390290603 283682280 54718...
output:
48119967363993
result:
ok answer is '48119967363993'
Test #11:
score: 0
Accepted
time: 51ms
memory: 14184kb
input:
200000 946595722 271213712 915506504 843189857 889214784 150802916 47950504 875914997 813247785 35791160 36350165 271403304 553268056 642299504 824405101 760788345 582500756 810890307 844167937 517445752 954178007 539167422 956565909 640348492 772207312 776135104 355220770 409647150 406776930 754956...
output:
49398629253632
result:
ok answer is '49398629253632'
Test #12:
score: 0
Accepted
time: 70ms
memory: 16180kb
input:
200000 474676011 939912865 348389405 320057032 401730779 772694363 522559450 449397650 84577374 772638546 454036490 511546084 450152378 361510375 736170896 868337032 233134669 593272303 521368545 910823164 807700292 524313138 209216902 471719411 93601829 139239405 320779934 441796820 979537222 16444...
output:
49741688559332
result:
ok answer is '49741688559332'
Test #13:
score: 0
Accepted
time: 77ms
memory: 16236kb
input:
200000 109397543 143192033 948668698 815492316 724901105 620108314 698967424 360842287 755198103 180096873 94781007 498090054 977844902 23263014 766839886 91213121 401300673 360200922 31701400 481563828 71448349 278872261 492714526 983119401 499513604 154303065 208383011 942154652 116109138 50732665...
output:
49786042407145
result:
ok answer is '49786042407145'
Test #14:
score: 0
Accepted
time: 230ms
memory: 28536kb
input:
200000 261992073 430909777 926146925 252251819 677218593 568716743 908238045 661028536 139554984 409946901 500485900 106878666 866267660 873908781 889662294 441992527 580144564 430178452 766191560 763853446 251057656 399523045 657208230 289791746 758935460 495002956 936637415 295647787 117309049 752...
output:
49900955205738
result:
ok answer is '49900955205738'
Test #15:
score: 0
Accepted
time: 131ms
memory: 16220kb
input:
500000 543196303 520001257 135913319 141681743 72855073 102021396 17954772 995707282 533540003 144014914 804630833 49605709 207753044 457005411 880119304 425402060 566315173 703211964 652934484 672802538 674426047 85342051 819455751 579118746 150110202 364244420 947318917 16739938 751932263 60777782...
output:
124534814723946
result:
ok answer is '124534814723946'
Test #16:
score: 0
Accepted
time: 133ms
memory: 18252kb
input:
500000 971792225 794146129 785511712 194135736 44786844 284152939 194083613 817410592 373146814 22622070 711767340 635823706 921756845 722623917 642611556 926642211 92896466 995135854 734765984 941700506 602652059 987869882 834639871 519669444 336528375 96478137 76254564 60733961 164313053 748831540...
output:
124240327455168
result:
ok answer is '124240327455168'
Test #17:
score: 0
Accepted
time: 278ms
memory: 23700kb
input:
1000000 129069570 702294568 125097641 447480588 218836298 281325716 362050097 11943415 717507041 299560656 434156157 308361506 374777194 802395549 673723185 424560671 314086825 759987836 872157780 803022722 656075017 128973367 589636307 233569636 120180505 318294358 777728766 964983779 323489034 471...
output:
249813673995070
result:
ok answer is '249813673995070'
Test #18:
score: 0
Accepted
time: 286ms
memory: 27300kb
input:
1000000 281228710 985743097 719261722 552388573 897858624 645588802 714307780 510125843 246977559 766326585 543396467 190349116 653041693 598473776 903740393 572265166 927057923 343835616 770979563 225720546 217559745 929510118 474780354 824222648 347792658 927985985 890375867 612780336 853283317 19...
output:
249986866979625
result:
ok answer is '249986866979625'
Test #19:
score: 0
Accepted
time: 379ms
memory: 30652kb
input:
1000000 578612043 564158922 18458508 802520750 136689461 450043377 771598167 448499760 221158478 528059809 92828265 512528215 931306192 539776195 573949090 719969661 394804829 632716100 934642563 208226883 484077177 879789973 214700209 709842955 15596299 537677612 297990264 700768381 528301792 33505...
output:
249189618339640
result:
ok answer is '249189618339640'
Test #20:
score: 0
Accepted
time: 454ms
memory: 38496kb
input:
1000000 263709877 249145493 400170549 868915888 960002504 272680394 425758139 683024665 544365499 455242644 229535590 115994789 932297247 13518365 684834337 895852392 202945750 509480961 234126953 296485671 284011673 437262033 105473744 332199902 773743475 411091856 764394619 98779195 374616388 3310...
output:
249839772035172
result:
ok answer is '249839772035172'
Test #21:
score: 0
Accepted
time: 1ms
memory: 10072kb
input:
30 499096833 933417495 882103125 787425402 648972887 700946219 839122735 37379635 486445119 773907603 874486646 797822652 717107686 406388292 751203987 283378903 299862157 797984363 883292224 626917047 37657097 1815525 504484877 101245061 932308294 263386821 768674270 511612127 460995775 145889490 1...
output:
6489728870
result:
ok answer is '6489728870'
Test #22:
score: 0
Accepted
time: 1ms
memory: 10104kb
input:
200 34354700 862581412 59106770 676268610 653416907 983569753 403068219 792195902 270806575 41006271 692592611 884245279 201896291 582381918 565138036 64485820 4283571 879203200 591051007 906053877 705789716 764558261 766342520 154746153 331191193 309272399 920183863 109834686 613776895 710009063 36...
output:
31837335420
result:
ok answer is '31837335420'
Test #23:
score: 0
Accepted
time: 0ms
memory: 10108kb
input:
1000 268499703 957112864 455900330 100247751 404796282 488787131 505894877 758603162 232359976 974696772 939286817 343845003 213739473 21884711 890858141 963344620 749244311 485404222 838987281 61567940 263295859 176714075 432430926 830176845 20946608 329581250 520460985 432801398 261834350 34105207...
output:
121840338190
result:
ok answer is '121840338190'
Test #24:
score: 0
Accepted
time: 2ms
memory: 12164kb
input:
1000 700543916 173893013 580621135 886721124 484812637 686502044 872697499 731469794 607847992 690178016 646398170 33467773 211272946 784751438 523215447 423995211 383516946 544620997 335599991 267566999 85960564 107995035 827605805 617042784 826857671 661388057 188738435 988060375 17520655 11584281...
output:
126448553496
result:
ok answer is '126448553496'
Test #25:
score: 0
Accepted
time: 3774ms
memory: 15308kb
input:
100000 935860805 985130033 782895781 739086796 859970843 504969873 982451813 339193953 830829630 960098998 479744296 32119815 336992875 584329585 21227100 413370515 253619426 879496633 736806966 888735291 778873833 229331239 929308203 742474269 799800137 23697530 170099575 333815481 559003343 660053...
output:
12435736939200
result:
ok answer is '12435736939200'
Test #26:
score: 0
Accepted
time: 2312ms
memory: 14736kb
input:
157000 829866708 578710232 578289776 318538299 852913519 750677882 671283794 150002526 202571035 711505399 600531693 723375332 382097903 274922450 440273782 830226754 632134243 635449230 98899400 98846765 607974353 501804853 603503841 446897953 212568315 695165652 255658851 878141405 670359172 19477...
output:
19617637311024
result:
ok answer is '19617637311024'
Test #27:
score: -100
Time Limit Exceeded
input:
197000 117046507 294174572 130091424 361455370 367089920 175915150 104474173 300684917 324943689 141992180 1303636 455340314 433441682 747082801 558418241 85409130 630572010 154613176 76532966 286208507 725546275 39249761 342927912 676962313 289520982 815485928 655188848 493362160 623950940 54884798...