Skip to content

Commit 15ec0b6

Browse files
Create Root of the Problem.cpp
1 parent 51ac2d3 commit 15ec0b6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
void solve()
5+
{
6+
int no_of_vertices;
7+
cin >> no_of_vertices;
8+
9+
int parent_id_sum = 0, child_id_sum = 0;
10+
for(int i = 1; i <= no_of_vertices; i++)
11+
{
12+
int parent, child_sum;
13+
cin >> parent >> child_sum;
14+
15+
parent_id_sum += parent;
16+
child_id_sum += child_sum;
17+
}
18+
19+
int root = parent_id_sum - child_id_sum;
20+
cout << root << "\n";
21+
}
22+
23+
int main()
24+
{
25+
int no_of_test_cases;
26+
cin >> no_of_test_cases;
27+
28+
while(no_of_test_cases--)
29+
solve();
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)