#include <iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,u,v,z;
bool d=1;
long long unsigned suma=0;
cin>>n;
for (int i=0;i<n-1;i++)
{cin>>u>>v>>z;
if (z>0)
{suma+=z;
d=0;}
}
if (d==1) {cout<<"0";}
else {cout<<suma;}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,u,v,z; bool d=1; long long unsigned suma=0; cin>>n; for (int i=0;i<n-1;i++) {cin>>u>>v>>z; if (z>0) {suma+=z; d=0;} } if (d==1) {cout<<"0";} else {cout<<suma;} return 0; } |
English