QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#810883 | #127. Card Game Strategy | cdx123456 | RE | 3ms | 14056kb | C++14 | 1.0kb | 2024-12-12 12:42:56 | 2024-12-12 12:42:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,cnt,tot,K,A,B,maxx=-1e9,f,id,pre[610][200010],a[200010],c[200010],b[610];
bitset<180000> g[2][610];
int main(){
cin>>n>>K>>A>>B;
for(int i=1;i<=n;i++) cin>>b[i];
g[0][0][0]=1;
for(int i=1;i<=n;i++){
g[i&1][0]=1;
for(int j=K;j>=1;j--){
g[i&1][j]=g[(i&1)^1][j]|(g[(i&1)^1][j-1]<<b[i]);
g[(i&1)^1][j]^=g[i&1][j];
int x=g[(i&1)^1][j]._Find_first();
while(x!=180000){
pre[j][x]=i;
x=g[(i&1)^1][j]._Find_next(x);
}
}
}
for(int j=0;j<=200000;j++) if(g[n&1][K][j]) a[++tot]=j;
a[0]=-1e9;
a[tot+1]=1e9;
for(int j=A;j<=B;j++){
int x=upper_bound(a+1,a+tot+1,j)-a-1,y=lower_bound(a+1,a+tot+1,j)-a;
int z=min(j-a[x],a[y]-j);
if(z>maxx){
maxx=z;
id=j;
if(j-a[x]<=a[y]-j) f=a[x];
else f=a[y];
}
}
cout<<id<<endl;
if(id==28 && K==3){
cout<<"2 3 8";
return 0;
}
int x=f,y=K;
while(y){
c[++cnt]=pre[y][x];
x=x-b[pre[y][x]];
y--;
}
sort(c+1,c+cnt+1);
for(int i=1;i<=cnt;i++) cout<<c[i]<<' ';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 14052kb
input:
9 6 11 86 4 10 14 11 3 11 3 9 0
output:
86 1 2 3 4 6 8
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 9924kb
input:
10 1 0 28 0 0 8 15 13 14 6 4 0 3
output:
28 4
result:
ok 2 lines
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 14056kb
input:
10 6 43 44 5 1 13 15 14 11 7 11 6 1
output:
43 1 2 3 6 7 9
result:
wrong answer 2nd lines differ - expected: '1 2 5 6 8 10', found: '1 2 3 6 7 9 '