QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#405229 | #8024. Fountains | Tomato_Fish# | WA | 1ms | 20088kb | C++14 | 1.6kb | 2024-05-05 14:32:13 | 2024-05-05 14:32:14 |
Judging History
answer
#include<bits/stdc++.h>
#define pi (3.14159265358979323846)
using namespace std;
typedef long double db;
typedef long long ll;
const int mod=998244353;
const int N=1e6+100;
const db eps=1e-12;
int mi(int x,int t){
int d=1;
while(t){
if(t%2) d=(ll)d*x%mod;
x=(ll)x*x%mod;t/=2;
}
return d;
}
int ni(int x) {return mi(x,mod-2);}
int a[15];ll qz[15];
struct node{
int l,r;ll c;
}g[110];
bool cmp(node n1,node n2) {return (n1.c>n2.c);}
ll sta[46][110000][2];int tot[46];
unordered_map<ll,int> B[46];
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
qz[0]=0;for(int i=1;i<=n;i++) qz[i]=qz[i-1]+a[i];
int cnt=0;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++){
g[++cnt].l=i;g[cnt].r=j;
g[cnt].c=qz[j]-qz[i-1];
}
sort(g+1,g+cnt,cmp);
sta[0][1][0]=sta[0][1][1]=0;
tot[0]=1;
for(int i=1;i<=cnt;i++){
bitset<45> P=0;
for(int j=1;j<=cnt;j++)
if(g[j].l<=g[i].l&&g[j].r>=g[i].r){
P.set(j-1);
}
for(int k=i-1;k>=0;k--){
for(int j=1;j<=tot[k];j++){
bitset<45> t=P&((bitset<45>)sta[k][j][0]);
ll t2=P.to_ulong()|sta[k][j][0];
int tt=g[i].l*(n-g[i].r+1)-t.count();
int id=B[k+1][t2];
if(id==0){
id=B[k+1][t2]=++tot[k+1];
sta[k+1][tot[k+1]][0]=t2,sta[k+1][tot[k+1]][1]=0;
}
sta[k+1][id][0]=t2;sta[k+1][id][1]=max(sta[k+1][id][1],g[i].c*tt+sta[k][j][1]);
}
}
}
ll Ans=0;
for(int i=1;i<=cnt;i++) Ans+=g[i].c;
for(int i=1;i<=cnt;i++){
ll mx=0;
for(int j=1;j<=tot[i];j++) mx=max(mx,sta[i][j][1]);
printf("%lld\n",Ans-mx);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5848kb
input:
1 1
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 9888kb
input:
2 13 24
output:
26 13 0
result:
ok 3 number(s): "26 13 0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 13988kb
input:
3 6 4 7
output:
33 21 12 8 4 0
result:
ok 6 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
1 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 14016kb
input:
3 1000000000 1000000000 1000000000
output:
6000000000 4000000000 3000000000 2000000000 1000000000 0
result:
ok 6 numbers
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 20088kb
input:
4 91 24 13 45
output:
402 267 185 137 100 52 39 26 13 0
result:
wrong answer 5th numbers differ - expected: '89', found: '100'