QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#874802 | #10026. Conditions | ship2077 | TL | 12ms | 4608kb | C++23 | 977b | 2025-01-28 16:38:46 | 2025-01-28 16:38:47 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int M=1e5+5;
int n,k,p=1,l,h,cnt,ans;
string str;int a[M],s[M];
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
signed main(){
n=read();k=read();
for (int i=1;i<=n;i++) a[i]=read();
sort(a+1,a+n+1);n=unique(a+1,a+n+1)-a-1;
ans=read();str=to_string(ans);
reverse(str.begin(),str.end());
l=(int)str.size()-1;
for (int i=0;i<=l;i++) s[i]=str[i]-'0',cnt+=s[i]==7;
while (p<=n&&a[p]<ans) p++;
while ((cnt>0)+(ans%k>0)+(ans==a[p])!=1){
p+=ans==a[p];ans++;h=-1;
for (int i=0;i<=l;i++)
if (s[i]==9) h=i;
else break;
if (s[h+1]==6) cnt++;
else if (s[h+1]==7) cnt--;
for (int i=0;i<=h;i++) s[i]=0;
s[h+1]++;l=max(l,h+1);
}
printf("%lld\n",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
5 9 181 182 184 178 81 173
output:
183
result:
ok 1 number(s): "183"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 888 888 888
output:
888
result:
ok 1 number(s): "888"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 2 446045505715847841 446045505715847840
output:
446045505715847840
result:
ok 1 number(s): "446045505715847840"
Test #4:
score: 0
Accepted
time: 11ms
memory: 4608kb
input:
100000 2 807962039062642490 880804964852722181 959725108988558937 594626785134501686 425482088894481449 676340104851509102 184450829310697710 631877387138697085 52728672294669025 360898372723015602 6758339167934099 169723381631741667 406281307220834232 11651333431455040 781335560876284346 8773369475...
output:
553478267720574478
result:
ok 1 number(s): "553478267720574478"
Test #5:
score: 0
Accepted
time: 9ms
memory: 4608kb
input:
100000 3 684875005129803765 709098012012528708 480894812691843935 192802234728574672 799328602200981241 816471042629902122 194852021641282532 699223097341173575 596346349877414625 176222175627714339 911245369353368570 429322911687891360 515479936110493603 318619854148565908 160597363142745651 195387...
output:
148669606523663815
result:
ok 1 number(s): "148669606523663815"
Test #6:
score: 0
Accepted
time: 11ms
memory: 4480kb
input:
100000 5 129494210963132304 277019632493463182 386180392318275419 520645308532061468 88972209392634514 669807243084456043 635809818965533308 715392780430009958 354309393033185135 549190749359853390 777757033042928397 905856356625845550 143774491908446012 574022081032628882 640426775109784241 1851134...
output:
300497756969678765
result:
ok 1 number(s): "300497756969678765"
Test #7:
score: 0
Accepted
time: 11ms
memory: 4480kb
input:
100000 7 630822406695744794 477299390470644195 325470478979428035 773343975310451318 860269241601790411 101706754174582047 211559169298240794 239266330575232906 746309663186601546 362697807276446450 939315921108841058 116129249092347232 650083292606092865 812361550420281815 226516627188856570 951699...
output:
288572584144291902
result:
ok 1 number(s): "288572584144291902"
Test #8:
score: 0
Accepted
time: 9ms
memory: 4480kb
input:
100000 25 51251644203166986 549351402988938382 694279130383632841 610525253804544230 684458492906151126 63232279536897262 728804590399630632 291342690465464012 194922149827118905 746519072305836528 209329582989387196 726180874956001415 356192042900226118 41271443347288072 320793885253192869 54527838...
output:
450584562204254438
result:
ok 1 number(s): "450584562204254438"
Test #9:
score: 0
Accepted
time: 11ms
memory: 4480kb
input:
100000 32 463368628487406643 32647027737340446 344652639707823670 414342912951134976 63972678207079586 972366953374863143 859270940516474839 784322982136643294 2430962027938898 432618021641274361 422102578966278816 812064681088426935 942541394200907148 386856316607581033 11960934554215668 5041449983...
output:
532870465189583872
result:
ok 1 number(s): "532870465189583872"
Test #10:
score: 0
Accepted
time: 12ms
memory: 4480kb
input:
100000 100 726365925473781288 924852326078181754 680717644501350132 942354243692678078 357845021224262895 184664913916063131 749794077317842485 444475377976962781 32723326228523426 715609806650973237 726148256788320316 804022754483820714 39483491261139602 435161988498900685 541146587201417187 326082...
output:
362668605596203312
result:
ok 1 number(s): "362668605596203312"
Test #11:
score: 0
Accepted
time: 11ms
memory: 4480kb
input:
100000 1000 213374267762435606 630244611191270176 270892479411716908 613708807444358255 800356952328819698 553899275792778005 737488305057083500 394268546663867130 735883788770776926 850875058688863503 668377457838859652 873643870954055067 262670968170311139 789750775255797395 313093051914250860 293...
output:
194667277645046000
result:
ok 1 number(s): "194667277645046000"
Test #12:
score: 0
Accepted
time: 11ms
memory: 4608kb
input:
100000 10000 452070894975760946 337069889090535748 892949699617554660 443760795735970006 342125240978475357 417709879885164419 906610750998236440 56898276610137316 75278311247943484 131799424501986167 251157111971599445 808114861853555350 72487575026078468 235500535254336056 873647535026452995 15786...
output:
114379812821900000
result:
ok 1 number(s): "114379812821900000"
Test #13:
score: 0
Accepted
time: 12ms
memory: 4608kb
input:
100000 100000 100389176858559494 313029182489444206 669454448895346361 593794830868581369 601202905778519705 780440644483437193 203838634811628902 560998404692185886 691897537625646765 503545870898705041 356866336175445747 703387109179580197 462612329667370863 129485094397505941 387080130384163501 6...
output:
463353164761600000
result:
ok 1 number(s): "463353164761600000"
Test #14:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
1 2 537276664084910570 537276664084910570
output:
537276664084910572
result:
ok 1 number(s): "537276664084910572"
Test #15:
score: 0
Accepted
time: 11ms
memory: 4608kb
input:
100000 2 657058652708446350 12762502111177639 693154353316161112 688573685969018423 436448232596181542 461517303561677778 97510370218705691 792370113335208696 256358888198872527 484830639004445687 663142686667410144 889759529504969767 303440668098206721 615862327938771347 541795617762320658 69312417...
output:
152985463838602184
result:
ok 1 number(s): "152985463838602184"
Test #16:
score: 0
Accepted
time: 12ms
memory: 4352kb
input:
100000 3 422573930999060047 468156986359341235 973363839847035945 925760825054715232 166807682347152912 6402421848208188 872584664306495819 127507882896675544 632958642394610516 919078393220325316 275553416262553673 477687929541749562 217043322488417892 631043295676748877 422146675524491828 28044315...
output:
234209450519813439
result:
ok 1 number(s): "234209450519813439"
Test #17:
score: 0
Accepted
time: 10ms
memory: 4480kb
input:
100000 5 917899629435813172 821452406212355177 764439288642343733 13006969206282077 990910934707417503 676721964847007194 968727167988272904 209380519019304315 437481742895273668 210877971066260101 740624230789581003 342849494329644441 14060356745455939 103200226110519212 757910561209072102 54112289...
output:
61466582150489868
result:
ok 1 number(s): "61466582150489868"
Test #18:
score: 0
Accepted
time: 11ms
memory: 4608kb
input:
100000 7 733352577980135097 637975568159555329 792414678365446789 181093582742648603 57719884092898512 107663465526580522 255552750680588227 645330076006215006 213453384626804643 368614399049747834 142451036532785203 376126025783037964 626781576701573054 191416087901831664 318327641550396324 6335555...
output:
428550339994458335
result:
ok 1 number(s): "428550339994458335"
Test #19:
score: 0
Accepted
time: 12ms
memory: 4480kb
input:
100000 25 741137895517691186 969839845387239581 532534169663149749 377625408513284753 697764289452611825 82047224606484697 762476925527924029 185797502272096640 507885745940658257 899796231485622276 802694241113217421 679629145664573740 36001778872908337 445404057276917153 350777525120852586 8483792...
output:
292519385136351280
result:
ok 1 number(s): "292519385136351280"
Test #20:
score: 0
Accepted
time: 12ms
memory: 4480kb
input:
100000 32 316187281146718022 318938121415421290 712307102907377854 686444787562118160 96201739386413593 393476846865646544 668759241684885135 516515327202931698 925780660122154359 541821684586891838 811914631794188861 616450874776191640 895142053360388775 480283365769279732 55512635543254716 6395918...
output:
806833261106381698
result:
ok 1 number(s): "806833261106381698"
Test #21:
score: 0
Accepted
time: 11ms
memory: 4608kb
input:
100000 100 748516621529491675 32866230907271385 368184676559599091 914316445170014794 324773429662794680 201687333423312962 96765045043866762 737261379273082179 52268561182724822 625291708226785265 689784523000011649 198600917267586915 278962590527313402 650496050544977131 622472780428985041 4875983...
output:
699549956480114244
result:
ok 1 number(s): "699549956480114244"
Test #22:
score: 0
Accepted
time: 12ms
memory: 4608kb
input:
100000 1000 152584936289196136 995057442038047919 312649101409831285 42309227188446875 682900328520650830 228843257530372407 277018263636254152 48626984453443472 774345072911970175 384142658487824917 895539902780656260 906494889898070842 138277744650328150 987504062278986530 58052573475061097 481924...
output:
313235219443882924
result:
ok 1 number(s): "313235219443882924"
Test #23:
score: 0
Accepted
time: 10ms
memory: 4480kb
input:
100000 10000 999029319403226910 162682223305115445 170487259389856944 264917474689087666 695591083169643477 867471357079280045 525093180671401430 708484398006918425 293940913678116883 683220727923783374 619881723450884457 537298741739958766 409007894736777505 590056575749101141 854146713642699330 37...
output:
340830169246012950
result:
ok 1 number(s): "340830169246012950"
Test #24:
score: 0
Accepted
time: 11ms
memory: 4352kb
input:
100000 100000 395838259997734970 180498190160473168 223689373138115897 571369046385279565 558044310510534508 986993690261136163 304910040725220441 460646019616741412 837006996194503485 427210514504766439 216318064809303910 252230321630412854 198719693834592546 149838139164289105 687820359957042171 5...
output:
456428480089881010
result:
ok 1 number(s): "456428480089881010"
Test #25:
score: -100
Time Limit Exceeded
input:
100000 92176 700000462790591200 700000464799567120 700000463272302976 700000459523228528 700000459712465856 700000456773249744 700000457345294000 700000456524743248 700000462901571104 700000461636732032 700000461670284096 700000456449896336 700000464558619056 700000458375176448 700000465123473584 70...