QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102544 | #5252. Deforestation | Kw1xotic | WA | 22ms | 12344kb | C++14 | 1.1kb | 2023-05-03 14:32:49 | 2023-05-03 14:32:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
int w,m,n;
int fa[MAXN];
int len[MAXN];
int cnt=0;
vector<int>edge[MAXN];
int inp(int fro)
{
int x,y;
scanf("%d%d",&x,&y);
cnt++;
len[cnt]=x;
fa[cnt]=fro;
int i;
int now=cnt;
for(i=1;i<=y;i++)
{
edge[now].push_back(inp(now));
}
return now;
}
int ans=0;
int sor[MAXN];
int dfs(int now)
{
if(edge[now].size()==0)
{
ans+=len[now]/w;
len[now]=len[now]%w;
return len[now];
}
int tmp=0;
sor[0]=0;
int i;
for(i=0;i<edge[now].size();i++)
{
int v=edge[now][i];
int res=dfs(v);
if(res>0)
{
tmp++;
sor[tmp]=res;
}
}
// printf("!!!%d %d\n",now,tmp);
sort(sor+1,sor+tmp+1);
int sum=0;
int tot=0;
for(i=1;i<=tmp;i++)
{
tot++;
sum+=sor[i];
if(sum>w)
{
tot--;
sum-=sor[i];
break;
}
}
ans+=tmp-tot;
len[now]+=sum;
ans+=len[now]/w;
len[now]=len[now]%w;
return len[now];
}
int main()
{
cnt=0;
scanf("%d",&w);
inp(0);
dfs(1);
if(len[1])
{
ans+=len[1]/w+(len[1]%w!=0);
}
printf("%d\n",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 19ms
memory: 8008kb
input:
999900000 7339 3 14947 2 12850 3 8986 10 11599 9 8889 10 10711 4 8015 1 11626 0 9492 1 7017 0 8863 0 8632 0 5321 5 9906 0 11687 0 9845 0 10469 0 11708 0 14950 5 11934 0 11922 0 13101 0 12000 0 9082 0 9273 5 12296 0 6119 0 9201 0 12652 0 12957 0 7454 5 12515 0 12976 0 10358 0 13997 0 8371 0 10181 5 8...
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 6ms
memory: 7188kb
input:
2 1 99999 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ...
output:
99999
result:
ok single line: '99999'
Test #3:
score: -100
Wrong Answer
time: 22ms
memory: 12344kb
input:
7 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10...
output:
142835716
result:
wrong answer 1st lines differ - expected: '142862500', found: '142835716'