Submission #286926


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int n,x,cc;
vector <int> h;
vector <int> a,b;

int saiki(int m, int cost, int num)
{
	if(cost == cc)
	{
		return num;
	}
	cost += h[m];
	
	return min(saiki(a[m],cost,++num),
	saiki(b[m],cost,++num) );
}

int main(void)
{
	
	cin >> n >> x;

	for(int i=0; i<n; i++)
	{
		int temp;cin >> temp;
		h.push_back(temp);
		cc+=temp;
	}
	for(int i=0; i<n; i++)
	{
		int temp;
		cin >> temp; a.push_back(temp);
		cin >> temp; b.push_back(temp);
	}
	
	cout << saiki(x,0,0) << endl;


	return 0;
}

Submission Info

Submission Time
Task B - ツリーグラフ
User chiwakii
Language C++ (G++ 4.6.4)
Score 0
Code Size 604 Byte
Status WA
Exec Time 2036 ms
Memory 256752 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
MLE × 2
AC × 1
WA × 2
TLE × 7
MLE × 10
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_line01.txt, subtask1_line02.txt, subtask1_line03.txt, subtask1_line04.txt, subtask1_line05.txt, subtask1_line06.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_special01.txt, subtask1_special02.txt, subtask1_special03.txt, subtask1_special04.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt MLE 736 ms 256744 KB
subtask0_sample_02.txt MLE 629 ms 256676 KB
subtask1_line01.txt WA 23 ms 792 KB
subtask1_line02.txt TLE 2030 ms 936 KB
subtask1_line03.txt TLE 2030 ms 884 KB
subtask1_line04.txt TLE 2030 ms 808 KB
subtask1_line05.txt TLE 2036 ms 924 KB
subtask1_line06.txt AC 20 ms 800 KB
subtask1_random01.txt MLE 642 ms 256680 KB
subtask1_random02.txt MLE 697 ms 256684 KB
subtask1_random03.txt MLE 635 ms 256680 KB
subtask1_random04.txt MLE 684 ms 256676 KB
subtask1_random05.txt MLE 708 ms 256664 KB
subtask1_random06.txt MLE 654 ms 256736 KB
subtask1_random07.txt MLE 677 ms 256676 KB
subtask1_random08.txt MLE 630 ms 256752 KB
subtask1_special01.txt WA 22 ms 676 KB
subtask1_special02.txt TLE 2030 ms 796 KB
subtask1_special03.txt TLE 2031 ms 804 KB
subtask1_special04.txt TLE 2030 ms 804 KB