Bismillahir Rahmanir Rahim
Thinking these case:
///Author: Tanvir Ahmmad
///CSE,Islamic University,Bangladesh
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<iterator>
#include <functional> ///sort(arr,arr+n,greater<int>()) for decrement of array
/*every external angle sum=360 degree
angle find using polygon hand(n) ((n-2)*180)/n*/
///Floor[Log(b) N] + 1 = the number of digits when any number is represented in base b
using namespace std;
typedef long long ll;
bool start[105],stop[105];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,u,v,weight,sum=0,oneside=0;
cin>>n;
while(n--)
{
cin>>u>>v>>weight;
if(stop[v] || start[u]) oneside+=weight,start[v]=stop[u]=true;
else start[u]=stop[v]=true;
sum+=weight;
}
ll otherside=sum-oneside;
cout<<min(oneside,otherside)<<endl;
return 0;
}
///Alhamdulillah
Problem Link: https://codeforces.com/contest/24/problem/A
Comments
Post a Comment