QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#424790#149. PeruHuasushis100 ✓48ms42928kbC++172.0kb2024-05-29 17:18:092024-09-10 16:46:15

Judging History

你现在查看的是最新测评结果

  • [2024-09-10 16:46:15]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:48ms
  • 内存:42928kb
  • [2024-05-29 17:18:09]
  • 评测
  • 测评结果:100
  • 用时:54ms
  • 内存:36192kb
  • [2024-05-29 17:18:09]
  • 提交

answer

#ifndef test
#include "peru.h"
#endif
#include <vector>
using namespace std;
using ll = long long;
#define N 2500010
#define mod 1000000007ll
ll f[N];
int* s;
struct deq {
  int stk[2][N], top[2];
  ll minn[2][N];
  deq() {minn[0][0] = minn[1][0] = 1e18;}
  bool empty() const {return !(top[0] + top[1]);}
  int front() const {
    if (top[0]) return stk[0][top[0]];
    return stk[1][1];
  }
  int back() const {
    if (top[1]) return stk[1][top[1]];
    return stk[0][1];
  }
  void pb(int x, ll v) {
    stk[1][++top[1]] = x;
    minn[1][top[1]] = min(v, minn[1][top[1] - 1]);
  }
  void pf(int x, ll v) {
    stk[0][++top[0]] = x;
    minn[0][top[0]] = min(v, minn[0][top[0] - 1]);
  }
  ll getmin() const { return min(minn[0][top[0]], minn[1][top[1]]); }
  void rebuild(int flg = 0) {
    int siz = top[0] + top[1];
    int mid = (siz + flg) / 2;
    vector<int> tmp;
    for (int i = top[0]; i; --i) tmp.emplace_back(stk[0][i]);
    for (int i = 1; i <= top[1]; ++i) tmp.emplace_back(stk[1][i]);
    top[0] = top[1] = 0;
    for (int i = mid - 1; ~i; --i) {
      if (empty()) pf(tmp[i], 1e18);
      else pf(tmp[i], f[tmp[i]] + s[front()]);
    }
    for (int i = mid; i < siz; ++i) {
      if (empty()) pb(tmp[i], 1e18);
      else pb(tmp[i], f[back()] + s[tmp[i]]);
    }
  }
  void pop_front() {
    if (!top[0]) rebuild(1);
    --top[0];
    if (!empty() && !top[0]) rebuild(1);
  }
  void pop_back() {
    if (!top[1]) rebuild();
    --top[1];
  }
}q;
int solve(int n, int k, int* s) {
  ::s = s;
  ll res = 0;
  for (int i = 0; i < n; ++i) {
    if (!q.empty() && q.front() <= i - k) q.pop_front();
    while (!q.empty() && s[q.back()] <= s[i]) q.pop_back();
    if (q.empty()) q.pb(i, 1e18);
    else q.pb(i, f[q.back()] + s[i]);
    f[i] = min(q.getmin(), (i >= k ? f[i - k] : 0) + s[q.front()]);
    res = (res * 23 + f[i]) % mod;
  }
  return res;
}
#ifdef test
int main() {
  int n = 8, k = 3;
  int s[] = {3, 2, 9, 8, 7, 11, 3, 4};
  cout << solve(n, k, s);
  return 0;
}
#endif

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 18
Accepted

Test #1:

score: 18
Accepted
time: 2ms
memory: 13900kb

input:

2000 170
1054018657 1037445664 1011691297 1009972317 1006506677 1002579733 999792775 999477541 975467893 970302369 968173111 957735623 953086083 938540451 932313113 930563895 924682633 917831575 913506401 908739591 905368525 899452913 894354220 890127447 885923007 583391543 880642788 878397752 87822...

output:

559335223

result:

ok single line: '559335223'

Test #2:

score: 18
Accepted
time: 2ms
memory: 13940kb

input:

2000 100
1019222751 1012312953 1005125581 978875481 967275037 967176717 965763637 960999157 957233281 956958729 953471924 942217905 936256081 925906257 922808341 918616993 918132100 915435367 911342035 909313549 902957201 902119531 900836861 99996937 892982026 884892282 884816596 884102145 883049077...

output:

818524087

result:

ok single line: '818524087'

Test #3:

score: 18
Accepted
time: 0ms
memory: 14248kb

input:

2000 20
1046023457 988320769 85389793 1819030505 635209701 362287065 747208901 958302681 957423952 1241659175 352880697 545051421 356189641 1678485313 76683576 940812217 995748541 1920846205 80556065 1358698601 483048309 1881187901 639822057 873315653 1157374529 225761262 1271878801 421346861 190846...

output:

722220390

result:

ok single line: '722220390'

Test #4:

score: 18
Accepted
time: 0ms
memory: 13952kb

input:

2000 30
1742393521 1373505943 1783981533 969067201 1868827930 1242849529 340585550 1430285741 1467707069 931245518 1652549049 1531083137 590083361 1624545751 90840583 920774329 1130261561 452306243 19102491 955643121 258267441 923161989 534143934 856297743 279514021 503065922 409174401 432771113 120...

output:

650653589

result:

ok single line: '650653589'

Test #5:

score: 18
Accepted
time: 2ms
memory: 13936kb

input:

2000 50
543424081 894641096 1339301255 1889686701 952129633 612233257 1547586801 364344001 432571137 1050383003 1137993587 685296321 666004060 67614961 585732097 121629576 1975355921 1465203126 1904792785 466104889 1562726309 1291336401 1942673537 1075318749 740251709 1038567681 1408927717 178247074...

output:

925458417

result:

ok single line: '925458417'

Test #6:

score: 18
Accepted
time: 1ms
memory: 14236kb

input:

2000 66
296941975 632767915 1762639311 958786399 1071923265 1552982561 216785941 1887579821 509308881 435656001 390210676 197780151 1301996771 1489698520 141918911 891666845 574475831 899508601 1013449051 175378801 89348801 837595313 270629113 279029177 384317601 1755443841 1235606561 1547972848 202...

output:

444646258

result:

ok single line: '444646258'

Test #7:

score: 18
Accepted
time: 1ms
memory: 13952kb

input:

2000 40
1059696721 1055166157 1044539161 1034355529 1030533441 1025978401 995197251 994572517 973608392 973353991 964014126 378408808 958025513 951750766 951037371 949770821 948486985 941198116 933949689 929560654 929512513 921764609 921307889 921167577 920417481 911390897 910270385 906125481 895972...

output:

7677983

result:

ok single line: '7677983'

Test #8:

score: 18
Accepted
time: 1ms
memory: 14032kb

input:

2000 20
1055110455 1005223324 1003873357 993841570 85534741 978021371 972929053 965514337 956876706 954140500 953747239 947700853 944007670 941645514 940364189 927465533 927214939 922020939 921390841 916331914 912757594 44655871 910441087 908052421 906270473 44773462 906022207 904501165 902742688 90...

output:

505871513

result:

ok single line: '505871513'

Test #9:

score: 18
Accepted
time: 1ms
memory: 14228kb

input:

2000 35
1022691767 1014414743 1011271745 1004244164 997794327 993850701 989771077 987749281 983716200 972060987 970129801 970068556 965852449 958249651 487933 958036353 956471803 948960379 948894321 948793357 947237281 130227931 937986316 937272479 932507293 932399201 928000385 27050453 922445926 92...

output:

211950235

result:

ok single line: '211950235'

Test #10:

score: 18
Accepted
time: 1ms
memory: 14244kb

input:

2000 50
1151914561 1495201451 1012909476 272883901 1725748641 950389217 206580001 1347030801 1931958771 1366894201 1250674465 1396662273 1905672559 1814735325 153639169 1199502271 1743930753 507709292 355904698 402770401 350650585 721029217 40258129 1743270991 207229381 435727781 1221323521 64386688...

output:

229458181

result:

ok single line: '229458181'

Test #11:

score: 18
Accepted
time: 0ms
memory: 13972kb

input:

2000 34
874023147 734709909 335190475 999498237 1581908993 272842689 1541974929 603853521 1502263105 1523850553 437313251 605618113 1252482079 1917808729 1839292253 1153661850 1768401651 970691571 296972777 1794594401 1898042336 1017506001 970010409 135942787 960588801 1817971441 1261276641 19492460...

output:

459414440

result:

ok single line: '459414440'

Test #12:

score: 18
Accepted
time: 0ms
memory: 14036kb

input:

2000 90
1945282221 581009181 63394299 627330027 1286388499 1097696131 1076306649 1761841621 1746358081 365563062 154009661 1801265786 1529431757 122058697 1381712677 411146001 1981007576 1167570621 1407588502 446110641 1597208705 414478041 1157817065 1614045761 1583648801 1166985591 1090632001 14515...

output:

198932165

result:

ok single line: '198932165'

Test #13:

score: 18
Accepted
time: 0ms
memory: 14232kb

input:

2000 101
1199509006 1918260001 1593549901 350489646 136788141 653292001 496126267 1074488441 184087969 697990641 1683056858 1992780276 705314881 403401873 771792621 236609025 1864750009 1505559241 1999940279 669693349 56972501 157466251 379727249 1265769875 347490626 1105199127 485967826 803890001 1...

output:

774419684

result:

ok single line: '774419684'

Test #14:

score: 18
Accepted
time: 1ms
memory: 13952kb

input:

2000 15
1689537321 898720501 1669337777 128316734 1978406108 1147164161 577488769 1844956801 1404644001 421025281 476255243 599476829 665843745 980993826 1894059905 152672733 330694871 1001232741 794930081 851019681 1611922961 1298969774 1580535251 1440923521 1225542751 1577310513 37273681 180104705...

output:

373845090

result:

ok single line: '373845090'

Subtask #2:

score: 31
Accepted

Test #15:

score: 31
Accepted
time: 9ms
memory: 17836kb

input:

400000 1000
1999989721 1999987224 1999984551 1999977673 1999977545 1999976801 1999975837 1999972607 1999956301 1999952801 1999942489 1999940593 1999940337 1999936353 1999936273 1999926073 1999925513 1999922980 1999918301 1999912501 1999909301 1999906125 1999902913 1999895622 1999893617 1999885490 19...

output:

677928817

result:

ok single line: '677928817'

Test #16:

score: 31
Accepted
time: 10ms
memory: 21584kb

input:

400000 800
1999974677 1999969921 1999965861 1999958493 1999958025 1999951391 1999947061 1999946921 1999944101 1999935101 1999934785 1999933729 1999933327 1999928689 1999921281 224119121 1999917457 1999914027 1999910181 1999903529 1999898241 1999890703 1999885291 1999877461 1999873851 1999865681 1999...

output:

390755425

result:

ok single line: '390755425'

Test #17:

score: 31
Accepted
time: 7ms
memory: 21632kb

input:

400000 450
1999991201 1999979985 1999975126 1999974440 1999968416 1999967617 1999961247 1999954759 1999945501 1999937001 1999936731 1999932397 1999931699 1999920033 1999919661 1999918093 1999913161 1999912681 1999901601 1999900001 1999892893 1999892117 1999892001 1999890311 1999887241 1999876001 199...

output:

365578785

result:

ok single line: '365578785'

Test #18:

score: 31
Accepted
time: 10ms
memory: 18488kb

input:

400000 500
440022081 1622703530 1063680545 1389784061 156690529 1044960001 1706989155 585548737 862752082 1938320961 1661424788 712296212 175535409 1843881991 992287026 1927314057 444990016 982477251 570841481 696788323 103688779 1719893793 425526289 963642805 497218401 1386584473 1375446512 4420463...

output:

247532529

result:

ok single line: '247532529'

Test #19:

score: 31
Accepted
time: 13ms
memory: 21552kb

input:

400000 650
1900456001 1904270001 68077633 123179649 797555089 498376481 1094348785 713705836 1795564891 1261056841 1480102753 285424785 821999875 1335202369 1875343841 315992801 1120959281 1385842626 768509251 795094479 713022001 510269921 1887870223 597184690 323561921 1669562206 724196281 10102726...

output:

183988362

result:

ok single line: '183988362'

Test #20:

score: 31
Accepted
time: 13ms
memory: 21352kb

input:

400000 1300
1806028931 1438649732 543808975 161507631 551736143 1408338501 1873943061 840318824 195546633 1044113181 850075401 1673847734 225047461 1320104618 1773423867 1711295841 1335980313 1283139634 192576486 475090593 593545985 1647896541 1373520957 565249356 10545726 840640517 330715201 193050...

output:

49006593

result:

ok single line: '49006593'

Test #21:

score: 31
Accepted
time: 4ms
memory: 18284kb

input:

400000 900
1999995133 1999993797 1999991878 1999991783 1999983777 1999981781 1999977249 1999975153 1999972581 1999971251 1999965201 1999959297 1999957761 1999951841 1999951305 1999949915 1999936321 1999935201 1999932953 1999926881 1999911777 1999906173 1999905351 1999898321 1999897971 1999878619 199...

output:

231789327

result:

ok single line: '231789327'

Test #22:

score: 31
Accepted
time: 11ms
memory: 21432kb

input:

400000 1900
1999999041 1999996876 1999992065 1999991523 1999989941 1999984597 1999982801 1999980755 1999966721 1999961515 1999960821 1999959601 1999950395 1999946001 1999938995 1999938101 1999921601 1999921165 1999919839 1999915521 1999914409 1999906229 1999890526 1999888705 1999883521 1999882501 19...

output:

497399601

result:

ok single line: '497399601'

Test #23:

score: 31
Accepted
time: 6ms
memory: 21256kb

input:

400000 2300
1999996581 1999995301 1999994497 1999993809 1999993585 1999991051 1999990101 1999974971 1999972961 1999969105 1999960211 1999958689 1999949601 1999946401 1999945193 1999944481 1999928561 1999924311 1999915181 1999911897 1999902969 1999894945 1999893836 1999893665 1999893593 1999888701 19...

output:

904238590

result:

ok single line: '904238590'

Test #24:

score: 31
Accepted
time: 7ms
memory: 21800kb

input:

400000 900
1999999209 1999997333 1999996361 1999981685 1999979785 1999978679 1999977457 1999977121 1999970433 1999969027 1999959781 1999953985 1999951531 1999948321 1999933341 1999931141 1999927851 1999924505 1999914471 1999913636 1999909241 1999906601 1999902545 1999898801 1999897509 1999892161 199...

output:

572758569

result:

ok single line: '572758569'

Test #25:

score: 31
Accepted
time: 7ms
memory: 21572kb

input:

400000 850
1999995169 1999986432 1999978001 1999972661 1999966449 1999951553 1999944641 1999943481 1999920201 1999912329 1999905561 1999898751 1999894529 1999887501 1999882981 1999881761 1999880561 1999876201 1999875521 1999873281 1999872061 1999867569 1999863026 1999860203 1999859737 1999858441 199...

output:

749891606

result:

ok single line: '749891606'

Test #26:

score: 31
Accepted
time: 9ms
memory: 18668kb

input:

400000 500
1999994079 1999991301 1999990365 1999984001 1999978345 1999967233 1999958609 1999941501 1999932441 1999923983 1999921751 1999917821 1999905901 1999901391 1999899490 1999893116 1999879201 1999876505 1999868429 1999862321 1999858226 1999834841 1999829601 1999826008 1999825618 1999823891 199...

output:

687211066

result:

ok single line: '687211066'

Test #27:

score: 31
Accepted
time: 4ms
memory: 18592kb

input:

400000 1300
1999989511 1999988401 1999988401 1999988351 1999986866 1999979611 1999972633 1999963421 1999956737 1999942001 1999937217 170230821 1999925249 1999920941 1999920001 1999917196 1999915631 1999915461 1999905799 1999902601 1999896001 1999893471 1999889001 1999879881 1999875983 1999875667 199...

output:

684392658

result:

ok single line: '684392658'

Test #28:

score: 31
Accepted
time: 0ms
memory: 21732kb

input:

400000 2000
1999994801 1999988327 1999988311 1999986321 1999985121 1999984479 1999973259 1999961801 1999961521 1999961226 1999953121 1999952514 1999939709 1999929471 1999928029 1999917835 1999906521 1999902071 1999895470 1999892585 1999892221 1999887585 1999885755 1999883276 1999880001 1999877351 19...

output:

964235081

result:

ok single line: '964235081'

Test #29:

score: 31
Accepted
time: 0ms
memory: 21900kb

input:

400000 5432
1999996581 1999995901 1999992577 1999981745 1999976601 1999959721 1999950491 1999949378 1999942369 1999934721 1999930881 1999923667 1999916358 1865412390 1999915071 1999909921 1999903233 1999899129 1999896798 1999893721 1999888832 1999882981 1999882714 1999880276 1999877121 1999874675 19...

output:

569690546

result:

ok single line: '569690546'

Test #30:

score: 31
Accepted
time: 7ms
memory: 21652kb

input:

400000 999
1999996037 1999994441 1999990032 1999989871 1999976071 1999964221 1999964099 1999960485 1999950961 1999932895 1999932325 1999904129 1999902397 1999895301 1999891089 1999880334 1999880087 1999873496 1999871201 1999868371 1508345140 1999866161 1999864931 1999864705 1999859785 1999858665 199...

output:

607828837

result:

ok single line: '607828837'

Test #31:

score: 31
Accepted
time: 7ms
memory: 18100kb

input:

400000 345
1999990873 1999987441 1999983927 1999981676 1999973121 1999969040 1999968257 1999968217 1999960001 1999946701 1999938921 1999922313 1999897691 1999889297 1999885401 1999877121 1999870817 1999867493 1999862717 1999858342 1999849094 1999845767 1999843751 1999842234 1999841801 1999838041 199...

output:

466507090

result:

ok single line: '466507090'

Test #32:

score: 31
Accepted
time: 3ms
memory: 21288kb

input:

400000 2900
1999983696 1999973121 1999971985 1999968209 1999950145 1999946753 1999943653 1999943605 1999942789 1999941233 1999936601 1999933575 1999932801 1999923657 1999921641 1999910617 1999909561 1999907841 1999901081 1999886105 1999882319 1999878081 1999866813 1999863921 1999862583 1999847745 19...

output:

578913981

result:

ok single line: '578913981'

Test #33:

score: 31
Accepted
time: 3ms
memory: 18284kb

input:

400000 300
1999999649 1999995361 1999994181 1999992801 1999988565 1999982003 1999969341 1999967461 1999960321 1999955781 1999954777 1999951641 1999946595 1999935030 1999920237 1999918067 1999914601 1999908081 1999906448 1999905281 1999904869 1999899361 1999896721 1999891466 1999884457 1999881401 199...

output:

617356184

result:

ok single line: '617356184'

Subtask #3:

score: 51
Accepted

Test #34:

score: 51
Accepted
time: 34ms
memory: 40616kb

input:

2500000 2000
1073315871 1073250349 1072791751 1072104046 1072071097 1071841833 1071809381 1071710686 1071580105 1071482003 1071383725 1071154701 1070499431 1070335288 1070334157 1069943617 1069681476 1069584279 1069581771 1069322519 1069189353 1069125955 1068832186 1068797487 1068662939 1068565681 1...

output:

12623259

result:

ok single line: '12623259'

Test #35:

score: 51
Accepted
time: 41ms
memory: 40600kb

input:

2500000 7700
1073053765 1072890026 1072529695 1072496806 1072464253 1072070707 1071776476 1071612499 1071482023 1071252612 1070990956 1070989988 1070924401 1070859816 1070761897 1070728924 1070728609 1070661817 1070367891 1070334353 1069976601 1069910201 1069844167 1069843321 1069778665 1069681476 1...

output:

962647496

result:

ok single line: '962647496'

Test #36:

score: 51
Accepted
time: 34ms
memory: 40576kb

input:

2500000 6000
1073381395 1072824492 1072627993 1072529745 1072529661 1072070887 1071546841 1071513973 1071317878 1071252801 1071187186 1071121456 1071121144 1070827397 1070434807 1070400409 1070268625 1070204353 1069747681 1068895612 1068895333 1068831809 1068796905 1068794865 1068728623 1068602599 1...

output:

24096464

result:

ok single line: '24096464'

Test #37:

score: 51
Accepted
time: 42ms
memory: 42928kb

input:

2500000 5000
1073283086 1073184841 1072627921 1072529745 1071449209 1071448761 1071317962 1070958241 1070957161 1070827433 1070663826 1070629051 1070565499 1070269017 1070236951 1070172027 1070008001 1069942252 1069940852 1069746406 1069681537 1069648801 1069646071 1069615801 1069615582 1069581129 1...

output:

564483941

result:

ok single line: '564483941'

Test #38:

score: 51
Accepted
time: 31ms
memory: 40576kb

input:

2500000 7000
1072726227 1072267661 1071580126 1071579202 1071546789 1071546735 1071252460 1071154671 1071055506 1070827147 1070826901 1070761015 1070531113 1070466564 1070401946 1070269017 1070007022 1069911319 1069778917 1069681212 1069678837 1069322645 1069319161 1069289805 1069123537 1069060771 1...

output:

915281751

result:

ok single line: '915281751'

Test #39:

score: 51
Accepted
time: 42ms
memory: 40564kb

input:

2500000 8333
1072922751 1072791757 1072169368 1071743895 1071743775 1071711106 1071678413 1071678403 1071645597 1071449065 1071416215 1070958351 1070958261 1070663358 1070433751 1070433167 1070402054 1070171677 1070074801 1069616401 1069223977 1069058143 1069028317 1068963022 1068859973 1068830486 1...

output:

889389722

result:

ok single line: '889389722'

Test #40:

score: 51
Accepted
time: 44ms
memory: 40656kb

input:

2500000 6500
1072333131 1072267765 1072201901 1071677621 1071645693 1071645681 1070925545 1070925226 1070891095 1070858496 1070661726 1070466849 1070368953 1070140354 1069942420 1069876081 1069845667 1069713337 1069518101 1069485369 1069452025 1069451785 1069387831 1069289560 1069254109 1069056953 1...

output:

802521424

result:

ok single line: '802521424'

Test #41:

score: 51
Accepted
time: 48ms
memory: 42640kb

input:

2500000 4900
1073512461 1073512459 1072267561 1072103761 1071776116 1071678277 1071448449 1071220159 1071220151 1071089147 1070860168 1070728844 1070301961 1070074161 1069942337 1069877658 1069845733 1069844641 1069744486 1069680036 1069649029 1069548701 1069452175 1069419361 1069322699 1069288912 1...

output:

696343398

result:

ok single line: '696343398'

Test #42:

score: 51
Accepted
time: 42ms
memory: 40688kb

input:

2500000 9000
1072660747 1072398625 1071842121 1071644913 1071121309 1071023153 1070990977 1070859921 1070696353 1070630419 1070565549 1070336173 1070205572 1070204197 1070171523 1070139214 1070107501 1070009326 1069649269 1069517983 1069486110 1069126495 1069124701 1068438289 1068407227 1068401733 1...

output:

402689022

result:

ok single line: '402689022'

Test #43:

score: 51
Accepted
time: 16ms
memory: 28296kb

input:

1000000 6000
1073053717 1071874211 1070499251 1070074920 1069584189 1069483294 1068959057 1068925075 1068467107 1068110724 1067785754 1067589436 1067162017 1066934961 1066729686 1066603721 1066577621 1066381669 1066115761 1066086202 1066054969 1065954801 1065912563 1065823010 1065792157 1065695737 1...

output:

822342391

result:

ok single line: '822342391'

Test #44:

score: 51
Accepted
time: 40ms
memory: 33688kb

input:

1500000 1000
138887169 842158381 854185856 1008551906 558399701 1921232339 595858841 613689679 95865441 1553418063 258787209 1651677551 456413373 1457714199 1114741601 1284973451 1569927577 345997866 1203601905 1659092481 1527605771 1948933841 1168252897 1379268111 218303478 1201952561 1634027741 15...

output:

135817932

result:

ok single line: '135817932'

Test #45:

score: 51
Accepted
time: 40ms
memory: 33824kb

input:

1500000 800
741260271 241938999 1152772721 1549929561 1115416703 755461951 1258240089 23159339 594135494 1615871017 1936949381 1600386945 674319601 699772245 1088403125 1045376689 1888481601 1043463661 1889301681 758461925 435428449 1730889201 1435919585 757632761 890565217 1642310781 47048751 10939...

output:

655285691

result:

ok single line: '655285691'

Test #46:

score: 51
Accepted
time: 39ms
memory: 32576kb

input:

1500000 1501
1262090145 548702161 829241651 462986015 119356747 231996525 1421143937 511154497 752003201 36454333 768700201 772415201 350898171 7748097 751433151 561685967 1410751633 411100093 1805847885 1598344801 189096513 1649150160 1903758441 1612420371 298392961 1236751131 863830721 379828793 7...

output:

247095642

result:

ok single line: '247095642'

Test #47:

score: 51
Accepted
time: 43ms
memory: 42692kb

input:

2500000 10000
1999998753 1999998129 1999996950 1999995001 1999994356 1999993749 1999992967 1999990106 1999989345 1999987713 1999986647 1999986145 1999985369 1999985313 1999985287 1999985136 1999984705 1999983431 1999982921 1999982467 1999980951 1999980729 1999978831 1999978565 1999978241 1999977957 ...

output:

549863660

result:

ok single line: '549863660'

Test #48:

score: 51
Accepted
time: 41ms
memory: 40712kb

input:

2500000 12050
1999999924 1999999055 1999998481 1999996353 1999995745 1999995681 1999995057 1999994743 1999994105 1999992945 1999992385 1999992161 1999992121 1999992041 1999990351 1999988545 1999987571 1999987473 1999983771 1999983601 1999983546 1999982521 1999982136 1999982033 1999981497 1999980801 ...

output:

408236191

result:

ok single line: '408236191'

Test #49:

score: 51
Accepted
time: 38ms
memory: 40928kb

input:

2500000 19000
1999999201 1999998891 1999998481 1999997601 1999997126 1999996591 1999996229 1999996005 1999995281 1999995013 1999994461 1999994413 1999994369 1999994301 1999994189 1999994029 1999992289 1999992051 1999990763 1999986929 1999986447 1999986299 1999986271 1999985731 1999985601 1999985345 ...

output:

873971033

result:

ok single line: '873971033'

Test #50:

score: 51
Accepted
time: 32ms
memory: 42772kb

input:

2500000 40000
1999999506 1999997937 1999997441 1999996561 1999996225 1999996053 1999996021 1999995901 1999995649 1999994253 1999991805 1999991801 1999991297 1999991105 1999990449 1999990373 1999989261 1999988951 1999988199 1999988081 1999988001 1999987601 1999986781 1999985481 1999985411 1999985393 ...

output:

585130146

result:

ok single line: '585130146'

Test #51:

score: 51
Accepted
time: 41ms
memory: 42716kb

input:

2500000 30000
1999998941 1999998735 1999998026 1999997351 1999996827 1999996610 1999996251 1999995521 1999995187 1999994897 1999994561 1999994540 1999994081 1999993022 1999992613 1999991361 1999990209 1999990009 1999986711 1999985763 1999985641 1999985631 1999985026 1999984421 1999982223 1999982017 ...

output:

103689571

result:

ok single line: '103689571'

Test #52:

score: 51
Accepted
time: 42ms
memory: 42768kb

input:

2500000 73000
1999999429 1999999097 1999996295 1999996185 1999995876 1999995867 1999995073 1999993409 1999993053 1999991844 1999991128 1999990961 1999990913 1999990401 1999989675 1999988401 1999988117 1999987817 1999987491 1999986321 1999986011 1999986001 1999983741 1999983041 1999982052 1999982001 ...

output:

446212528

result:

ok single line: '446212528'

Test #53:

score: 51
Accepted
time: 31ms
memory: 40928kb

input:

2500000 55555
1999999489 1999998820 1999998737 1999998691 1999998433 1999995621 1999995013 1999994841 1999993905 1999991801 1999991695 1999991686 1999991111 1999990161 1999987630 1999987561 1999984849 1999982529 1999982131 1999981697 1999981663 1999981156 1999981153 1999980801 1999980321 1999980001 ...

output:

628950038

result:

ok single line: '628950038'

Test #54:

score: 51
Accepted
time: 45ms
memory: 42640kb

input:

2500000 5000
1072988273 1072824453 1072627977 1072071277 1071973082 1071416551 1071317737 1071252820 1070892301 1070696543 1070696431 1070596720 1070467329 1070465761 1070336513 1070268625 1070237029 1070204897 1070107547 1069943876 1069646761 1069580899 1069484610 1069352486 1069351046 1069159201 1...

output:

730825361

result:

ok single line: '730825361'

Test #55:

score: 51
Accepted
time: 34ms
memory: 40620kb

input:

2500000 5000
1073217565 1073119317 1072889990 1072857181 1072398745 1071940269 1071809143 1071776524 1071449265 1071120464 1070532521 1070368561 1070336608 1070336488 1070042161 1069976809 1069976739 1069908841 1069845917 1069780401 1069680321 1069648675 1069515373 1069485726 1068928849 1068864787 1...

output:

124849779

result:

ok single line: '124849779'

Test #56:

score: 51
Accepted
time: 36ms
memory: 40816kb

input:

2500000 7000
1072627881 1072235022 1072103986 1072103689 1072005403 1071579785 1071317578 1070892745 1070827451 1070663113 1070270001 1070140369 1070041043 1069943260 1069877526 1069613662 1069582341 1069485921 1069387641 1069256245 11291344 1069155956 1069125451 1068799501 1068766744 1068734131 106...

output:

694607359

result:

ok single line: '694607359'

Test #57:

score: 51
Accepted
time: 40ms
memory: 42704kb

input:

2500000 5000
1072496713 1072333207 1072169368 1071645597 1071449065 1071448449 1071187433 1070990177 1070825971 1070663358 1070531518 1070401561 1070270650 1070203588 1070170327 1069812365 1069681861 1069681141 1069646975 1069616401 1069582761 1069551581 1069420661 1069420580 1069387453 1069224566 1...

output:

438722269

result:

ok single line: '438722269'

Test #58:

score: 51
Accepted
time: 33ms
memory: 40656kb

input:

2500000 5000
1073479688 1072824517 1072758946 1072496881 1072365866 1072202279 1071874849 1071808627 1071416467 1071351091 1070958309 1070794001 1070696101 1070073009 1069974555 1069878457 1069679188 1069551581 1069551496 1069516657 1069387503 1069289965 1069189353 1069156804 1069126375 1069092129 1...

output:

510254669

result:

ok single line: '510254669'

Test #59:

score: 51
Accepted
time: 33ms
memory: 40932kb

input:

2500000 5000
1073512455 1072791721 1072693405 1072234977 1071940209 1071743601 1071710641 1071645528 1071416095 1071383600 1071252460 1070827363 1070761015 1070729249 1070727604 1070565129 1070531281 1070530753 1070466564 1070434465 1070042177 1069680673 1069548481 1069516463 1069322645 1069091409 1...

output:

446451988

result:

ok single line: '446451988'

Test #60:

score: 51
Accepted
time: 32ms
memory: 42908kb

input:

2500000 5000
1072660753 1072627881 1072300117 1072235022 1072201861 1072103986 1072103689 1071678391 1071677563 1071612889 1071153843 1071023563 1070892745 1070434765 1070336401 1070270001 1070171601 1070140369 1070140306 1070107627 1069878633 1069877526 1069843717 1069582341 1069451155 1069387641 1...

output:

476721093

result:

ok single line: '476721093'

Test #61:

score: 51
Accepted
time: 44ms
memory: 42676kb

input:

2500000 12000
1999997649 1999997521 1999996849 1999996471 1999993585 1999992855 1999992841 1999992201 1999992121 1999991868 1999990267 1999989871 1999986305 1999986049 1999985473 1999985326 1999984925 1999984785 1999984625 1999983686 1999983595 1999982582 1999981960 1999981501 1999981201 1999981117 ...

output:

685817860

result:

ok single line: '685817860'

Test #62:

score: 51
Accepted
time: 42ms
memory: 42764kb

input:

2500000 11500
1999999329 1999998001 1999997937 1999997049 1999996861 1999994561 1999994125 1999993217 1999992609 1999992337 1999991721 1999991321 1999990001 1999989656 1999989506 1999988549 1999988317 1999988241 1999987887 1999986893 1999986851 1999984266 1999984191 1999982161 1999982051 1999981825 ...

output:

433115402

result:

ok single line: '433115402'

Test #63:

score: 51
Accepted
time: 43ms
memory: 40580kb

input:

2500000 8000
1999999647 1999998691 1999997793 1999997761 1999997465 1999997441 1999994881 1999994429 1999992451 1999992121 1999991681 1999990077 1999990001 1999990001 1999989813 1999988761 1999987051 1999986761 1999986229 1999984711 1999984657 1999982923 1999982223 1999981057 1999979751 1999979098 1...

output:

627733401

result:

ok single line: '627733401'