QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834195 | #9913. 绝顶之战 | hhoppitree# | 35 | 179ms | 37344kb | C++14 | 1.3kb | 2024-12-27 13:24:35 | 2024-12-27 13:24:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int n;
long long a[N];
vector<long long> res;
void dfs(int x, long long y, vector<long long> z) {
if (x == n + 1) {
res.push_back(y);
return;
}
sort(z.begin(), z.end());
if (z.back() > a[x] && y >= a[x]) {
for (int i = 0; i < (int)z.size(); ++i) {
if (z.back() > a[x]) {
long long v = z.back();
z.pop_back();
z.push_back(v - a[x]), z.push_back(v - a[x]);
dfs(x + 1, y - a[x], z);
z.pop_back(), z.pop_back();
z.insert(z.begin(), v);
}
}
}
long long ts = 0;
for (auto v : z) ts += min(v, a[x]);
if (ts <= y) return;
for (auto &v : z) v = min(v, a[x]);
dfs(x + 1, y, z);
}
signed main() {
long long m;
scanf("%lld%d", &m, &n);
for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
dfs(1, m, {m + 1});
sort(res.rbegin(), res.rend());
res.erase(unique(res.begin(), res.end()), res.end());
printf("%d\n", (int)res.size());
for (int i = 0; i < (int)res.size(); ++i) {
printf("%lld%c", m - res[i], " \n"[i + 1 == (int)res.size()]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 0ms
memory: 4088kb
input:
9 5 5 4 5 3 5
output:
3 5 8 9
result:
ok 4 number(s): "3 5 8 9"
Test #2:
score: 15
Accepted
time: 0ms
memory: 3796kb
input:
10 5 7 4 5 4 6
output:
1 7
result:
ok 2 number(s): "1 7"
Test #3:
score: 15
Accepted
time: 0ms
memory: 4084kb
input:
9 5 8 4 3 5 6
output:
1 8
result:
ok 2 number(s): "1 8"
Test #4:
score: 15
Accepted
time: 0ms
memory: 4100kb
input:
10 5 6 6 5 4 5
output:
2 6 10
result:
ok 3 number(s): "2 6 10"
Test #5:
score: 15
Accepted
time: 0ms
memory: 3800kb
input:
10 5 6 6 5 3 4
output:
2 6 9
result:
ok 3 number(s): "2 6 9"
Subtask #2:
score: 5
Accepted
Test #6:
score: 5
Accepted
time: 0ms
memory: 4088kb
input:
9146201596026093 2 1959292328727211 3046691025174768
output:
1 5005983353901979
result:
ok 2 number(s): "1 5005983353901979"
Test #7:
score: 5
Accepted
time: 0ms
memory: 3876kb
input:
9275681991750590 2 5186569060202341 3113841469169509
output:
2 5186569060202341 8300410529371850
result:
ok 3 number(s): "2 5186569060202341 8300410529371850"
Test #8:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
9401675366106951 2 149091771205127 6947611558612479
output:
2 149091771205127 7096703329817606
result:
ok 3 number(s): "2 149091771205127 7096703329817606"
Test #9:
score: 5
Accepted
time: 0ms
memory: 3876kb
input:
9392557811857168 2 160423759804827 7346645029161642
output:
2 160423759804827 7507068788966469
result:
ok 3 number(s): "2 160423759804827 7507068788966469"
Test #10:
score: 5
Accepted
time: 0ms
memory: 3740kb
input:
9822837057566509 2 108146351103958 7480790958348985
output:
2 108146351103958 7588937309452943
result:
ok 3 number(s): "2 108146351103958 7588937309452943"
Subtask #3:
score: 5
Accepted
Test #11:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
9107037180352846 3 2775941126614211 2097129959011760 1941377836547846
output:
2 4873071085625971 6814448922173817
result:
ok 3 number(s): "2 4873071085625971 6814448922173817"
Test #12:
score: 5
Accepted
time: 0ms
memory: 3876kb
input:
9356790767702598 3 5546180935211679 2905945428392309 1761953813389806
output:
2 7308134748601485 8452126363603988
result:
ok 3 number(s): "2 7308134748601485 8452126363603988"
Test #13:
score: 5
Accepted
time: 0ms
memory: 3740kb
input:
9850427814943989 3 142199778279844 6707702417646007 5098690319392154
output:
3 142199778279844 5240890097671998 6849902195925851
result:
ok 4 number(s): "3 142199778279844 5240890097671998 6849902195925851"
Test #14:
score: 5
Accepted
time: 0ms
memory: 4056kb
input:
9289721094295218 3 158922512595425 6720813049590970 5533326304480556
output:
3 158922512595425 5692248817075981 6879735562186395
result:
ok 4 number(s): "3 158922512595425 5692248817075981 6879735562186395"
Test #15:
score: 5
Accepted
time: 0ms
memory: 3800kb
input:
9089829946377332 3 153331859334767 6955566390185762 5391139066021841
output:
3 153331859334767 5544470925356608 7108898249520529
result:
ok 4 number(s): "3 153331859334767 5544470925356608 7108898249520529"
Subtask #4:
score: 5
Accepted
Test #16:
score: 5
Accepted
time: 0ms
memory: 3740kb
input:
9035514376902827 5 1861522865446152 1901640741231313 2239047273044626 2596933481542076 2408801444166990
output:
4 3763163606677465 6002210879722091 8411012323889081 8599144361264167
result:
ok 5 number(s): "4 3763163606677465 60022108797...11012323889081 8599144361264167"
Test #17:
score: 5
Accepted
time: 0ms
memory: 3792kb
input:
9720759307951601 5 5245904226180530 3078325181926984 1664005610640026 897140663439037 545770017429336
output:
5 7807050500259593 8324229408107514 8352820517688929 8869999425536850 9221370071546551
result:
ok 6 numbers
Test #18:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
9914984513811788 5 143280160480180 109619234770197 6890320393268943 5403376030977054 4137173786378446
output:
5 252899395250377 4390073181628823 5656275426227431 7143219788519320 9793449212605877
result:
ok 6 numbers
Test #19:
score: 5
Accepted
time: 0ms
memory: 3800kb
input:
9759176874761010 5 133219343571190 120466941665747 6704653967672701 5571405145717257 4167138211880141
output:
4 253686285236937 4420824497117078 5825091430954194 6958340252909638
result:
ok 5 number(s): "4 253686285236937 442082449711...25091430954194 6958340252909638"
Test #20:
score: 5
Accepted
time: 0ms
memory: 3860kb
input:
9525506737874968 5 148963131354572 158578418411159 6828452733024137 5381364252000234 4049653682935737
output:
4 307541549765731 4357195232701468 5688905801765965 7135994282789868
result:
ok 5 number(s): "4 307541549765731 435719523270...88905801765965 7135994282789868"
Subtask #5:
score: 5
Accepted
Test #21:
score: 5
Accepted
time: 0ms
memory: 3800kb
input:
9023163981511792 7 1910131726862762 2116561201938147 2221366112235172 2543084904983947 2627118050952859 1894287864736168 2673898998406780
output:
5 4026692928800909 5920980793537077 6248059041036081 8142346905772249 8791143946020028
result:
ok 6 numbers
Test #22:
score: 5
Accepted
time: 0ms
memory: 3888kb
input:
9201962815585483 7 5414508209828189 3093292941553917 1685274817103741 948835864411768 509817155946068 281984678231046 159476022063405
output:
11 8051060883172449 8490079591638149 8558436047289766 8667277173445511 8717912069353171 8789785829613152 8840420725520812 8949261851676557 8999896747584217 9017618307328174 9177094329391579
result:
ok 12 numbers
Test #23:
score: 5
Accepted
time: 0ms
memory: 3744kb
input:
9826610363201771 7 162505577758383 135338647957173 6721075735733948 5272016953171334 3778424372952824 2933545141068482 2192801947755330
output:
11 4076268598668380 5424191314539368 5569861178886890 6269070546423710 7009813739736862 7018919961449504 7762663126642220 8503406319955372 9202615687492192 9211721909204834 9348285551839714
result:
ok 12 numbers
Test #24:
score: 5
Accepted
time: 0ms
memory: 3860kb
input:
9130499502023512 7 155672196353335 159186169334854 143660830359863 7428948651751866 5151447515782955 3798505869621088 3051456865715739
output:
7 458519196048052 3509976061763791 4257025065669140 5609966711831007 7308481931384879 7887467847799918 8661423577546746
result:
ok 8 numbers
Test #25:
score: 5
Accepted
time: 0ms
memory: 3856kb
input:
9787957086564562 7 187238348793225 123717981911599 129684193048160 6696615131438344 5283070868135540 3906283631465365 2886113099800319
output:
8 440640523752984 3326753623553303 4346924155218349 5723711391888524 7137255655191328 7233037255018668 8609824491688843 9629995023353889
result:
ok 9 numbers
Subtask #6:
score: 0
Wrong Answer
Test #26:
score: 5
Accepted
time: 0ms
memory: 3812kb
input:
9843534281138117 9 2077071368628181 2828099538983996 3196114494343630 3055890563571162 2057088847509186 2194463607939255 2091779370708588 3167995993737888 2800516708286895
output:
6 4905170907612177 6962259755121363 7961061471183339 8101285401955807 9054039125829951 9156723363060618
result:
ok 7 numbers
Test #27:
score: 0
Wrong Answer
time: 3ms
memory: 3860kb
input:
9089321288577479 9 5013478738969552 3157961240306159 1653601571668037 995106965792662 547346063380849 294963106466152 160268607573676 93635792107328 51921499739784
output:
18 7815215379905378 8262976282317191 8515359239231888 8611960377588975 8650053738124364 8678593193055323 8716686553590712 8758400845958256 8770707542396344 8772228985162651 8810322345698040 8864343334503672 8879054650230236 8930976149970020 8972690442337564 9013749149122712 9024611942077348 90656706...
result:
wrong answer 1st numbers differ - expected: '17', found: '18'
Subtask #7:
score: 0
Wrong Answer
Test #31:
score: 10
Accepted
time: 0ms
memory: 3808kb
input:
9431564240371856 11 2072502046158126 2066316271517661 2163529290633843 2033552924777258 2060295112538633 2170963915845858 2830153069449699 2750192266102216 2436460356484587 2070428523960501 2346826281628005
output:
5 4138818317675787 6172371242453045 6302347608309630 8232666354991678 8335900533086888
result:
ok 6 numbers
Test #32:
score: 0
Wrong Answer
time: 179ms
memory: 37344kb
input:
9748017886882097 11 5621106261846239 2963693598568387 1770987181252029 893130050604348 502107706153055 286239930406429 177406459478434 98736836706145 50305470562766 29068874911746 16153459380560
output:
37 8552112180697403 8943134525148696 9159002300895322 9242710891860706 9267835771823317 9281172208128898 9346505394595606 9359841830901187 9394936760738985 9445242231301751 9458578667607332 9468675301829182 9517106667972561 9567412138535327 9573457715874046 9595776290744850 9617012886395870 96218890...
result:
wrong answer 1st numbers differ - expected: '35', found: '37'
Subtask #8:
score: 0
Time Limit Exceeded
Test #36:
score: 10
Accepted
time: 0ms
memory: 3800kb
input:
9205033666499013 12 2850462003249404 2805242660077069 2429054981777503 2963815386637346 2482550367349595 1986471485219802 2520994127845999 2437529223970625 2627469170446910 1921642320209105 2645728927620059 2290578758228158
output:
4 5655704663326473 7577346983535578 7642176148546275 8084759645103976
result:
ok 5 number(s): "4 5655704663326473 75773469835...42176148546275 8084759645103976"
Test #37:
score: 0
Time Limit Exceeded
input:
9312008144548179 12 5098312777552324 2828210584202914 1698846116084863 972763022136388 536323112196116 296239601985823 168374174447656 95736456798989 55681139272124 31357956485449 16061655649327 9384457843970
output:
result:
Subtask #9:
score: 0
Time Limit Exceeded
Test #41:
score: 10
Accepted
time: 0ms
memory: 4084kb
input:
9386101775874151 13 2988434015746527 2531638596517047 2952017129004226 2532501379103299 2134686632728924 2723134092613376 2734705006477432 2790707225133977 2417142090510094 2242777209869653 2707931539021407 2508571481588074 2833570313484694
output:
4 5520072612263574 7654759244992498 8052573991366873 8472089741267800
result:
ok 5 number(s): "4 5520072612263574 76547592449...52573991366873 8472089741267800"
Test #42:
score: 0
Time Limit Exceeded
input:
9168182173116105 13 5245945745965630 2966339978381958 1587236525258288 896003981667415 529285939890159 293959638682944 169587396142065 91544716767044 52705601201500 28282607177863 17370633326495 9113216610963 5470267979344
output:
result:
Subtask #10:
score: 0
Time Limit Exceeded
Test #46:
score: 30
Accepted
time: 1ms
memory: 4060kb
input:
9001324849976175 14 2825925335672803 2025589127489736 2269614904415361 1837491879093462 2158539836494236 2426078823971452 1924825856346157 2746394845754343 2268412247933575 2230951690565408 2494052463977166 2855920747842645 2234733913430870 2001499177846439
output:
6 4851514463162539 6689006342256001 7121129367577900 8613832198602158 8847546178750237 8958621246671362
result:
ok 7 numbers
Test #47:
score: 0
Time Limit Exceeded
input:
9972282568532949 14 5505337530293470 3041608956429561 1641948100087404 921229203322626 522006830353828 305104880869052 169979965880291 98139538460294 50438074200129 30572008666021 16022716436664 9778663336212 5597214430013 3030746040166