QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#792507 | #686. Bad Doctor | hzylbd | WA | 2ms | 13888kb | C++14 | 1.4kb | 2024-11-29 10:59:30 | 2024-11-29 10:59:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n,m;
int c[500010];
int l[500010],r[500010],k[500010];
bool yao[5010][5010];
int len[500010],y[500010];
int ma[1000010];
int x;
int ld;
bool f[5010];
long long ans;
int main()
{
//freopen("doctor.in","r",stdin);
//freopen("doctor.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin >> n >> m;
for (int i=1;i<=m;i++) cin >> c[i];
if (n>1&&m==1)
{
for (int i=1;i<=n;i++) cin >> l[i] >> r[i] >> k[i] >> x;
ans=c[1]*n;
for (int i=1;i<=n;i++)
{
for (int j=l[i];j<=r[i];j++)
{
ma[j]++;
}
}
cout << ans;
}
else if (n<=5000)
{
for (int i=1;i<=n;i++)
{
cin >> l[i] >> r[i] >> k[i];
ld=max(ld,r[i]);
for (int j=1;j<=k[i];j++) cin >> x,yao[i][x]=true;
}
for (int i=1;i<=n;i++)
{
ans=0;
for (int j=1;j<=ld;j++)
{
memset(f,false,sizeof f);
for (int k=1;k<=n;k++)
{
if (i==k) continue;
if (j>=l[k]&&j<=r[k])
{
for (int a=1;a<=m;a++)
{
if (yao[k][a]&&!f[a])
{
ans+=c[a];
f[a]=true;
}
}
}
}
}
cout << ans << " ";
}
}
else
{
for (int i=1;i<=n;i++)
{
cin >> l[i] >> r[i] >> k[i];
len[i]=r[i]-l[i]+1;
for (int j=1;j<=k[i];j++) cin >> x,y[i]+=c[x];
ans+=y[i]*len[i];
}
for (int i=1;i<=n;i++) cout << ans-1ll*y[i]*len[i] << " ";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 13888kb
input:
5 4 1000 100 10 1 3 4 2 2 3 4 8 3 1 2 4 6 7 2 3 4 8 9 2 1 4 2 6 3 1 2 3
output:
8766 7564 8756 7765 6646
result:
ok 5 number(s): "8766 7564 8756 7765 6646"
Test #2:
score: 0
Accepted
time: 2ms
memory: 13800kb
input:
1 1 1 1 1 1 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 13860kb
input:
1 2 10 1 1 2 1 2
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 11880kb
input:
2 1 1 1 2 1 1 3 4 1 1
output:
2
result:
wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements