QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#828398 | #9913. 绝顶之战 | Hanghang | 10 | 6ms | 17632kb | C++20 | 791b | 2024-12-23 16:28:09 | 2024-12-23 16:28:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=15,M=(1<<14)+3,INF=1e18;
ll n,m,a[N],sum[M];
unordered_map<ll,ll>F[N][M];
ll Dfs(ll x,ll S,ll T)
{
if(x==n)return INF;
if(F[x][S].count(T))return F[x][S][T];
ll &s=F[x][S][T];s=-INF;
if(!(S>>x&1))return s=min(a[x],Dfs(x+1,S,T));
if(!(T>>x&1))return s=Dfs(x+1,S^(1<<x),T);
int now=T^(1<<x);S^=1<<x;
for(int v=now;;v=(v-1)&now)
{
s=max(s,Dfs(x+1,S,v)+Dfs(x+1,S,now^v));
if(!v)break;
}
return s+=a[x];
}
int main()
{
cin>>m>>n;set<ll>ans;
for(int i=0;i<n;i++)cin>>a[i];
for(int S=0;S<(1<<n);S++)sum[S]=sum[S^(S&-S)]+a[__builtin_ctz(S)];
for(int S=0;S<(1<<n);S++)if(sum[S]<=m&&m<Dfs(0,S,S))ans.insert(sum[S]);
cout<<ans.size()<<endl;
for(auto it:ans)cout<<it<<" ";
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 15
Accepted
time: 6ms
memory: 17024kb
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: 5ms
memory: 17004kb
input:
10 5 7 4 5 4 6
output:
1 7
result:
ok 2 number(s): "1 7"
Test #3:
score: 15
Accepted
time: 3ms
memory: 16892kb
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: 17044kb
input:
10 5 6 6 5 4 5
output:
2 6 10
result:
ok 3 number(s): "2 6 10"
Test #5:
score: 0
Wrong Answer
time: 5ms
memory: 16888kb
input:
10 5 6 6 5 3 4
output:
3 6 9 10
result:
wrong answer 1st numbers differ - expected: '2', found: '3'
Subtask #2:
score: 5
Accepted
Test #6:
score: 5
Accepted
time: 2ms
memory: 17020kb
input:
9146201596026093 2 1959292328727211 3046691025174768
output:
1 5005983353901979
result:
ok 2 number(s): "1 5005983353901979"
Test #7:
score: 5
Accepted
time: 5ms
memory: 17012kb
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: 16948kb
input:
9401675366106951 2 149091771205127 6947611558612479
output:
2 149091771205127 7096703329817606
result:
ok 3 number(s): "2 149091771205127 7096703329817606"
Test #9:
score: 5
Accepted
time: 2ms
memory: 17016kb
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: 16876kb
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: 2ms
memory: 17020kb
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: 16948kb
input:
9356790767702598 3 5546180935211679 2905945428392309 1761953813389806
output:
2 7308134748601485 8452126363603988
result:
ok 3 number(s): "2 7308134748601485 8452126363603988"
Test #13:
score: 5
Accepted
time: 3ms
memory: 16884kb
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: 2ms
memory: 17172kb
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: 6ms
memory: 17008kb
input:
9089829946377332 3 153331859334767 6955566390185762 5391139066021841
output:
3 153331859334767 5544470925356608 7108898249520529
result:
ok 4 number(s): "3 153331859334767 5544470925356608 7108898249520529"
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 2ms
memory: 17180kb
input:
9035514376902827 5 1861522865446152 1901640741231313 2239047273044626 2596933481542076 2408801444166990
output:
7 3763163606677465 6002210879722091 6171965050844455 6360097088219541 8411012323889081 8599144361264167 8768898532386531
result:
wrong answer 1st numbers differ - expected: '4', found: '7'
Subtask #5:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 0ms
memory: 17020kb
input:
9023163981511792 7 1910131726862762 2116561201938147 2221366112235172 2543084904983947 2627118050952859 1894287864736168 2673898998406780
output:
13 4026692928800909 5920980793537077 6248059041036081 6569777833784856 6653810979753768 6700591927207689 8142346905772249 8464065698521024 8548098844489936 8594879791943857 8791143946020028 8875177091988940 8921958039442861
result:
wrong answer 1st numbers differ - expected: '5', found: '13'
Subtask #6:
score: 0
Wrong Answer
Test #26:
score: 0
Wrong Answer
time: 3ms
memory: 17096kb
input:
9843534281138117 9 2077071368628181 2828099538983996 3196114494343630 3055890563571162 2057088847509186 2194463607939255 2091779370708588 3167995993737888 2800516708286895
output:
13 4905170907612177 6962259755121363 6996950278320765 7099634515551432 7705687615899072 7961061471183339 8073166901350065 8101285401955807 9054039125829951 9156723363060618 9191413886260020 9762776463408258 9797466986607660
result:
wrong answer 1st numbers differ - expected: '6', found: '13'
Subtask #7:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 0ms
memory: 17296kb
input:
9431564240371856 11 2072502046158126 2066316271517661 2163529290633843 2033552924777258 2060295112538633 2170963915845858 2830153069449699 2750192266102216 2436460356484587 2070428523960501 2346826281628005
output:
45 4138818317675787 6172371242453045 6199113430214420 6209246841636288 6302347608309630 6309782233521645 6485644599303792 6575278674160374 6889010583778003 6968971387125486 8232666354991678 8242799766413546 8269541954174921 8335900533086888 8343335158298903 8362642720848263 8370077346060278 83727761...
result:
wrong answer 1st numbers differ - expected: '5', found: '45'
Subtask #8:
score: 0
Wrong Answer
Test #36:
score: 0
Wrong Answer
time: 0ms
memory: 17248kb
input:
9205033666499013 12 2850462003249404 2805242660077069 2429054981777503 2963815386637346 2482550367349595 1986471485219802 2520994127845999 2437529223970625 2627469170446910 1921642320209105 2645728927620059 2290578758228158
output:
11 5655704663326473 7577346983535578 7642176148546275 7946283421554631 8084759645103976 8093233887297098 8138255030676068 8176698791172472 8283173833773383 8301433590946532 8619520049963819
result:
wrong answer 1st numbers differ - expected: '4', found: '11'
Subtask #9:
score: 0
Wrong Answer
Test #41:
score: 0
Wrong Answer
time: 0ms
memory: 17268kb
input:
9386101775874151 13 2988434015746527 2531638596517047 2952017129004226 2532501379103299 2134686632728924 2723134092613376 2734705006477432 2790707225133977 2417142090510094 2242777209869653 2707931539021407 2508571481588074 2833570313484694
output:
12 5520072612263574 7654759244992498 7762849822133227 7937214702773668 8028644093851648 8052573991366873 8228004151284981 8243206704876950 8254777618741006 8310779837397551 8353642925748268 8472089741267800
result:
wrong answer 1st numbers differ - expected: '4', found: '12'
Subtask #10:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 3ms
memory: 17632kb
input:
9001324849976175 14 2825925335672803 2025589127489736 2269614904415361 1837491879093462 2158539836494236 2426078823971452 1924825856346157 2746394845754343 2268412247933575 2230951690565408 2494052463977166 2855920747842645 2234733913430870 2001499177846439
output:
22 4851514463162539 6689006342256001 6776340319508696 6853013641008978 7010054299656775 7082466153727947 7086248376593409 7119926711096114 7121129367577900 7277593287133991 7345566927139705 7597909308916882 7707435211005184 8613832198602158 8690505520102440 8777839497355135 8847546178750237 89199580...
result:
wrong answer 1st numbers differ - expected: '6', found: '22'