QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#86674 | #5657. Hungry Cow | Scintilla | 4.545455 | 579ms | 132008kb | C++14 | 2.0kb | 2023-03-10 15:29:59 | 2023-03-10 15:30:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, s, e) for (int i = s; i <= e; ++i)
#define drep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define pv(a) cout << #a << " = " << a << endl
#define pa(a, l, r) cout << #a " : "; rep(_, l, r) cout << a[_] << ' '; cout << endl
const int P = 998244353;
const int i2 = (P + 1) / 2;
const int N = 1e5 + 10;
const int M = N * 40;
const int W = 1e14;
int read() {
int x = 0, f = 1; char c = getchar();
for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;
for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
return x * f;
}
#define ls lson[u]
#define rs rson[u]
#define mid (l + r >> 1)
int s1(int l, int r) {
return (l + r) % P * (r - l + 1) % P * i2 % P;
}
int tot, cnt[M], out[M], res[M], lson[M], rson[M];
int calc(int k, int u, int l, int r) {
if (!k) return res[u];
if (k + cnt[u] >= r - l + 1) return s1(l, r);
if (k + cnt[ls] <= mid - l + 1) {
return (calc(k, ls, l, mid) + res[rs]) % P;
}
else {
int rest = k + cnt[ls] - (mid - l + 1);
return (s1(l, mid) + calc(rest, rs, mid + 1, r)) % P;
}
}
void maintain(int u, int l, int r) {
int t = min(r - mid - cnt[rs], out[ls]);
cnt[u] = cnt[ls] + cnt[rs] + t;
out[u] = out[ls] - t + out[rs];
res[u] = res[ls] + calc(min(out[ls], t), rs, mid + 1, r);
}
int modify(int p, int k, int u, int l, int r) {
if (!u) u = ++ tot;
if (l == r) {
cnt[u] = min(k, 1ll), out[u] = k - cnt[u];
res[u] = cnt[u] * l;
return u;
}
if (p <= mid) ls = modify(p, k, ls, l, mid);
else rs = modify(p, k, rs, mid + 1, r);
return maintain(u, l, r), u;
}
#undef ls
#undef rs
#undef mid
int n;
signed main() {
n = read(), tot = 1;
rep(i, 1, n) {
int p = read(), k = read();
modify(p, k, 1, 1, W);
printf("%lld\n", res[1]);
}
return 0;
}
详细
Test #1:
score: 4.54545
Accepted
time: 4ms
memory: 9676kb
input:
3 4 3 1 5 1 2
output:
15 36 18
result:
ok 3 number(s): "15 36 18"
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 9576kb
input:
9 1 89 30 7 101 26 1 24 5 1 60 4 5 10 101 0 1 200
output:
4005 4656 4962 3446 3471 3717 4017 1066 24531
result:
wrong answer 3rd numbers differ - expected: '7607', found: '4962'
Test #3:
score: 0
Wrong Answer
time: 15ms
memory: 13192kb
input:
5000 1 255364995 414918035 212844 1 112266691 321122438 191414 1 277615842 848755093 61676 1 432591689 892259443 53755 1 263753018 173404455 173565 1 178341924 878941367 221276 1 65332960 439468128 240741 1 812238377 191076090 108732 1 180383041 927440330 112995 1 595696140 579818784 85614 1 5057816...
output:
6124449923 13934782710 14188420227 21961607692 13921202946 19701358556 12664373717 20858542844 27711110601 27604721644 35029451770 39230373109 44057958095 49145182289 7239566221 6950641160 48432265056 55244053981 31653120192 31478615132 32069976986 31774494239 31549776776 31552809806 70753453871 755...
result:
wrong answer 1st numbers differ - expected: '235118030', found: '6124449923'
Test #4:
score: 0
Wrong Answer
time: 203ms
memory: 132008kb
input:
100000 1 500000000 1000000001 500000000 2000000001 500000000 3000000001 500000000 4000000001 500000000 5000000001 500000000 6000000001 500000000 7000000001 500000000 8000000001 500000000 9000000001 500000000 10000000001 500000000 11000000001 500000000 12000000001 500000000 13000000001 500000000 1400...
output:
7077658245 13515107586 20310592376 20476402144 21000247361 20883883674 22123799789 21725262647 21684760954 21518605664 22194174869 22229535170 21624686567 22376117766 22487340061 21622661233 22449954426 21638794362 22473239948 22378150782 21642852712 22263834444 22409740225 21750304149 22447147875 2...
result:
wrong answer 1st numbers differ - expected: '375000007', found: '7077658245'
Test #5:
score: 0
Wrong Answer
time: 309ms
memory: 73716kb
input:
100000 49998999950002 500000000 49997999950003 500000000 49996999950004 500000000 49995999950005 500000000 49994999950006 500000000 49993999950007 500000000 49992999950008 500000000 49991999950009 500000000 49990999950010 500000000 49989999950011 500000000 49988999950012 500000000 49987999950013 500...
output:
50006572575690 50009691274638 100014551290724 150020551515714 150016221666498 200015518110119 250017951251350 250017218664232 300016941001506 350017803547684 350011922375279 400007079384441 449999383625095 449997517238466 499993100141281 549985830275588 549982632198794 549983569063963 59997772333627...
result:
wrong answer 1st numbers differ - expected: '376399979', found: '50006572575690'
Test #6:
score: 0
Wrong Answer
time: 259ms
memory: 98136kb
input:
100000 92303348842417 121458 92270522994821 852054850 93765096269940 752161890 97779083359973 984327853 90030769679569 439157849 99462493683485 45660 95578441605501 614317411 92236129196525 474149928 96065411631989 429943696 90394247621798 382840249 89263934750729 791122796 93577089467158 99679481 9...
output:
92307740420326 184584510452436 278354302862840 376146195641932 466187407417676 565653010934273 661239934769454 661208451195291 757279140258217 847682060520483 936955423043054 1030538857355579 1126326950759911 1223846475988261 1316205203875470 1413163631478445 1501705376690749 1501705095588238 160060...
result:
wrong answer 1st numbers differ - expected: '601385635', found: '92307740420326'
Test #7:
score: 0
Wrong Answer
time: 221ms
memory: 97904kb
input:
100000 98001410246890 641673458 94816407430628 495030536 95979591652947 43208 95979591652947 183686 97163521776290 904784415 91640049592559 875129980 95914835187460 844802426 94846379383324 974270031 99639652388956 311664277 99298294827771 913614463 99476866913169 221766107 97248342663994 669489020 ...
output:
98009706658372 192834919018689 288820650114242 288821098029738 385987766485943 477635058683055 573560041768391 668413550260863 768059401916572 867366041910979 966853342146009 1064111435791892 1162435411255719 1262337998507546 1354354163582329 1446629875727102 1546003194660501 1645576090682121 173748...
result:
wrong answer 1st numbers differ - expected: '805408268', found: '98009706658372'
Test #8:
score: 0
Wrong Answer
time: 260ms
memory: 97504kb
input:
100000 97338601145206 191999210 97657969728741 875988993 92559675348135 8552565 99354409480201 960853995 93648768326445 343671323 97400841247229 104463842 98844341051398 508718383 96144328794112 187050711 98030257583732 365513 92378049740181 852725611 98301676983212 360931360 99458914124366 80234576...
output:
97348822435993 195019406048191 287586559517683 386947817218683 480606531064104 578012122847817 676865360885556 773017128996486 871050100212994 963436960846755 1061747408645300 1161215015338907 1254904158274294 1354171602905307 1446409326035565 1538170531184875 1634553949749588 1731986982583466 18277...
result:
wrong answer 1st numbers differ - expected: '201835835', found: '97348822435993'
Test #9:
score: 0
Wrong Answer
time: 227ms
memory: 97372kb
input:
100000 96119987448606 658315028 98644701118435 280992389 98180676447908 56168 99822794299596 237183170 94655838918825 563695131 95744558879343 686204820 93739311062176 263266841 97630990881452 96901680 98683433984282 380708175 98141920320037 147598812 98095513966598 814629225 97882900659205 55097258...
output:
96127411353148 194779846394958 292965460039376 392794962335609 487458968577597 583212708967481 676956864871044 774595543578062 873289784814803 971438653117816 971393710429618 1069283343570624 1162642844965357 1162643505782663 1257074196790108 1355029616080490 1450487103543581 1549583315379521 164611...
result:
wrong answer 1st numbers differ - expected: '284288958', found: '96127411353148'
Test #10:
score: 0
Wrong Answer
time: 219ms
memory: 94652kb
input:
100000 98169641631056 170946511 99452522210742 393032132 98797460964704 393706377 98747209012224 529219651 99152468691953 362194103 99410753036475 215295 97096873124809 1315725 96106202009957 124516158 95176405230280 853965254 99359463136784 622839995 96635771520630 550456203 96368792029394 93630831...
output:
98176106159887 197634264946123 296437887186108 395191865099352 494348358094147 593764341195427 690871170475241 786984766559059 882169734457779 981535153736268 1078179533795832 1174557189639793 1272466147221809 1369993487716772 1466996405647612 1566986527286614 1663144591190698 1758356985179804 18550...
result:
wrong answer 1st numbers differ - expected: '692991104', found: '98176106159887'
Test #11:
score: 0
Wrong Answer
time: 160ms
memory: 78836kb
input:
100000 97499080763005 475255826 97499083333242 9347 97499080763005 395470349 97499924236501 4654 97499080763005 148122052 97499213182916 2365 97499080763005 544025506 97499777050346 9912 97499080763005 41736833 97499401163067 12607 97499080763005 127843558 97499125181305 7144 97499080763005 13152858...
output:
97505753118432 97505713179665 97505093415165 97505139729603 97505253188507 97505624890502 97505080632117 97505770588499 97505794987850 97504997828808 97505101920565 97505615380556 97505573611044 97505231254861 97505491056937 97505133300239 97505875265433 97505869677740 97505227606796 97505219522173 ...
result:
wrong answer 1st numbers differ - expected: '655956691', found: '97505753118432'
Test #12:
score: 0
Wrong Answer
time: 163ms
memory: 75452kb
input:
100000 98999026537234 929244389 98999182418499 5182 98999026537234 774643967 98999646433835 17857 98999026537234 760743518 98999980664456 7597 98999026537234 573421161 98999090975969 6621 98999026537234 95191521 98999947586610 17798 98999026537234 953104244 98999116462517 15643 98999026537234 100617...
output:
99011205479881 99011243450589 99011752749000 99011313473844 99011762723052 99011299078831 198011794607909 198012190233256 297014264463859 396016898995743 99011081888999 99011749640376 396016816969462 495020196568705 297014399648550 396017414607391 99011459690503 99011535430453 495022848229591 594025...
result:
wrong answer 1st numbers differ - expected: '526240962', found: '99011205479881'
Test #13:
score: 0
Wrong Answer
time: 169ms
memory: 74760kb
input:
100000 99499024212061 630391525 99499061152079 3864 99499024212061 16505706 99499878275777 4812 99499024212061 776185964 99499757280269 12059 99499024212061 356565635 99499399237611 8902 99499024212061 972528120 99499256994518 9171 99499024212061 419476867 99499909552451 17146 99499024212061 6767939...
output:
99504793403955 99505060741055 99504261657405 199009133712430 99505042515931 99504833552014 298513404083641 298513568146794 99505055548274 99504354022461 298513179739661 398018695634697 99504454276442 99504955546423 99504667002055 99505094221079 99504967060338 99504598053256 497522589548745 497522405...
result:
wrong answer 1st numbers differ - expected: '358833000', found: '99504793403955'
Test #14:
score: 0
Wrong Answer
time: 544ms
memory: 70872kb
input:
99999 10490328589436 1000000000 13762508396295 1000000000 40632115714511 1000000000 32834989282081 1000000000 29091918306598 1000000000 24352818172350 1000000000 23447797352860 1000000000 38073075086135 1000000000 14288530509239 1000000000 36463049009868 1000000000 10562334120356 1000000000 34490016...
output:
10498836561684 24268590450438 64910661214808 97753320869035 126853549209886 151217101574351 174671109825058 212752500588099 227049445328749 263519532131167 274093305701235 308590343310160 347004110222051 382579983902245 408304487395248 422318111935270 432781448132085 458277880932639 471340626743121 ...
result:
wrong answer 1st numbers differ - expected: '700388007', found: '10498836561684'
Test #15:
score: 0
Wrong Answer
time: 577ms
memory: 71156kb
input:
99999 61585049539216 1000000000 58981995705940 1000000000 44247484521936 1000000000 70916218483207 1000000000 47696673638497 1000000000 60781033156530 1000000000 55859922511212 1000000000 59143999312357 1000000000 57175954090596 1000000000 71328224891428 1000000000 46047599292678 1000000000 47510666...
output:
61591658539672 120586222520510 164846501124266 235771815308090 283474972379272 344265507708321 400132957071048 459286180300261 516469081768606 587803577134325 633861177712829 681382921675666 744385378185683 788704254266846 859122219176840 933288106343402 1001861665181188 1060542745069758 11216049802...
result:
wrong answer 1st numbers differ - expected: '656243188', found: '61591658539672'
Test #16:
score: 0
Wrong Answer
time: 579ms
memory: 71116kb
input:
99999 21219982576425 1000000000 42260400232639 1000000000 26412110792985 1000000000 11035481121988 1000000000 13219690258669 1000000000 19550933913223 1000000000 32679237390903 1000000000 15679803374289 1000000000 23896051833122 1000000000 20099950455987 1000000000 14778766729432 1000000000 21547991...
output:
21225829402789 63495760306982 89915748767447 100959866051208 114187733563973 133747605897548 166435233615968 182124772149586 206033616083674 226141671997092 240926904168850 262485439371808 297214306971628 326944882796545 348110990152308 380185956755827 403361061900621 441299595340606 478373177045393...
result:
wrong answer 1st numbers differ - expected: '123004833', found: '21225829402789'
Test #17:
score: 0
Wrong Answer
time: 547ms
memory: 68924kb
input:
99999 28503598869279 1000000000 32397709666940 1000000000 25833502058723 1000000000 38020841213328 1000000000 54560138759501 1000000000 42230929758874 1000000000 28972613620824 1000000000 28498598787317 1000000000 54070131397843 1000000000 22084267818956 1000000000 37776835952805 1000000000 44465973...
output:
28510971548295 60918067943907 86757380551369 124783342514191 179350922070872 221589561332152 250566196127882 279070443436046 333149187387558 355243205364928 393026700743209 437501103261689 464309960800992 515323502774462 547212617157172 587408915552576 613394649899505 663380235509798 715479358370454...
result:
wrong answer 1st numbers differ - expected: '809311757', found: '28510971548295'
Test #18:
score: 0
Wrong Answer
time: 564ms
memory: 71136kb
input:
99999 18175781548542 1000000000 40883228277118 1000000000 33828113807745 1000000000 17817771477758 1000000000 22749897023579 1000000000 18015777423352 1000000000 28920025506062 1000000000 18799798298070 1000000000 27979006765970 1000000000 17103749421004 1000000000 24329932307643 1000000000 29798042...
output:
18183908987899 59078350602461 92913182728732 110741076162935 133502958952120 151527260933539 180455829386990 199265228788370 227254590859908 244366590532312 268706388350121 298512592193414 327826553303498 363074382804818 375739326917734 417127537957874 450878165546497 472172286480538 485796618750221...
result:
wrong answer 1st numbers differ - expected: '530050851', found: '18183908987899'
Test #19:
score: 0
Wrong Answer
time: 559ms
memory: 70900kb
input:
99999 13631696063382 1000000000 19095823575649 1000000000 18048800926387 1000000000 17060779354093 1000000000 15768748767399 1000000000 30886037572930 1000000000 26814970558482 1000000000 8165534157289 1000000000 27914989206121 1000000000 34170089895536 1000000000 27764986366439 1000000000 145187181...
output:
13638635432223 32740406149296 50798923471269 67866518858368 83645708865023 114541508485852 141363584888167 149539034615645 177461489154694 211643804967632 239418672212489 253945517873767 286884943681383 307578343971554 323313204131018 351823092779167 380249742227994 393282807204189 402090952880681 4...
result:
wrong answer 1st numbers differ - expected: '128224308', found: '13638635432223'
Test #20:
score: 0
Wrong Answer
time: 555ms
memory: 70956kb
input:
99999 71091006018203 1000000000 42267334298998 1000000000 53421686894439 1000000000 52992676205010 1000000000 49055576058012 1000000000 70721000416119 1000000000 43151374327143 1000000000 70716000332404 1000000000 51528640431406 1000000000 65945925001029 1000000000 39524135856472 1000000000 66414932...
output:
71099961072193 113375120625825 166804607842079 219806242957215 268868674567749 339596298659319 382756909186060 453481719098779 505016483206896 570971112664773 610503698857353 676926931946062 744396925413255 801027098445871 867944337814951 910688035297174 960574685764585 1012688220988850 108291457090...
result:
wrong answer 1st numbers differ - expected: '961356073', found: '71099961072193'
Test #21:
score: 0
Wrong Answer
time: 563ms
memory: 70876kb
input:
99999 43981987091230 1000000000 41793950053258 1000000000 23385527966154 1000000000 32049759202175 1000000000 48927065970165 1000000000 26694629471843 1000000000 27661655640242 1000000000 37241867113918 1000000000 49110069037684 1000000000 20323405372655 1000000000 43304975621086 1000000000 48021052...
output:
43990009304108 85790383733656 109186267503303 141246680212855 190181312905205 216883606713318 244550134884847 281796933735635 330915466598386 351246831925312 394559459501246 442588864201682 475390414854976 502030163345314 533458609089435 561686466758820 607899042586974 642413960797315 68734078058154...
result:
wrong answer 1st numbers differ - expected: '92516536', found: '43990009304108'
Test #22:
score: 0
Wrong Answer
time: 579ms
memory: 71012kb
input:
99999 31159466866911 1000000000 28413414847308 1000000000 25948364344910 1000000000 31236468095715 1000000000 22036273821032 1000000000 24056321657736 1000000000 36031551606814 1000000000 37935581367999 1000000000 40624624246259 1000000000 18857191994835 1000000000 22179277697755 1000000000 29154428...
output:
31166383227223 59586126347968 85541663549997 116786283865840 138829019619009 162891282805652 198931935942781 236875069257291 277504863043646 296368224072732 318554413088815 347717017772479 388134437444175 402689985709475 413627067285383 444655899936420 480975031035724 519481452088249 547215793642254...
result:
wrong answer 1st numbers differ - expected: '733458470', found: '31166383227223'