QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102496#5252. Deforestationzswzswzsw#WA 48ms30364kbC++14745b2023-05-03 13:58:112023-05-03 13:58:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 13:58:13]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:30364kb
  • [2023-05-03 13:58:11]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=501000;
int n,W,tA=1;
vector<int>G[N];
int val[N];
int build(void)
{
	int u=++tA,siz;
	cin>>val[u]>>siz;
	for(int i=1;i<=siz;i++)G[u].push_back(build());
	return u;
}
int res=0;
bool cmp(int x,int y){
	return val[x]<val[y];
}
void DFS(int u)
{
	int sum=0;
	for(int i=0,v;i<G[u].size();i++)
	{
		v=G[u][i];
		DFS(v);sum+=val[v];
	}
	sort(G[u].begin(),G[u].end());
	int siz=G[u].size();
	while(sum>W)++res,sum-=val[G[u][siz-1]],--siz;
	//if(u==2)cout<<sum<<' '<<res<<endl;
	val[u]+=sum;
	res+=val[u]/W;val[u]%=W;
	return;
}
signed main()
{
	cin>>W;
	G[1].push_back(build());
	DFS(1);
	if(val[1])++res;
	cout<<res;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 41ms
memory: 18028kb

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: 36ms
memory: 16784kb

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: 0
Accepted
time: 47ms
memory: 22576kb

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:

142862500

result:

ok single line: '142862500'

Test #4:

score: 0
Accepted
time: 31ms
memory: 30364kb

input:

2
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10000 1
10...

output:

500000000

result:

ok single line: '500000000'

Test #5:

score: -100
Wrong Answer
time: 48ms
memory: 19424kb

input:

9717
14907 2
6953 2
10004 2
10949 2
11766 2
14015 2
5640 2
10370 2
6432 2
7602 2
10238 2
9755 2
5788 2
10885 2
11858 2
9182 2
14174 0
12614 0
12080 1
12497 0
7708 2
9108 1
14948 0
9107 1
13540 0
7400 2
6303 2
14462 1
8021 0
7659 1
7232 0
14314 2
9495 1
8459 0
13069 1
5777 0
12734 2
7061 2
12810 2
13...

output:

108570

result:

wrong answer 1st lines differ - expected: '105756', found: '108570'