1 #include <iostream>
2 #include <cstring>
3 #include <cstdio>
4 using namespace std;
5 typedef long long LL;
6 const int N=100010;
7 int n,cnt,fir[N],nxt[N<<1],to[N<<1];
8 LL val[N<<1],dis[N],ans,sum,Mx;
9 LL u1[N],v1[N],b[N],c[N];
10 LL u2[N],v2[N];
11 bool ring[N];
12 void addedge(int a,int b,int v){
13 nxt[++cnt]=fir[a];
14 val[cnt]=v;
15 fir[a]=cnt;
16 to[cnt]=b;
17 }
18
19 int ID[N],tot;
20 int st[N],top;
21 int pre[N];
22 void DFS(int x){
23 ID[x]=++tot;
24 for(int i=fir[x],y;i;i=nxt[i])
25 if((y=to[i])!=pre[x]){
26 if(!ID[y]){
27 pre[y]=x;
28 c[y]=val[i];
29 DFS(y);
30 }
31 else if(ID[y]>ID[x]){
32 while(x!=y){
33 st[++top]=y;
34 b[top]=c[y];
35 ring[y]=true;
36 y=pre[y];
37 }
38 st[++top]=x;
39 b[top]=val[i];
40 ring[x]=true;
41 return;
42 }
43 }
44 }
45
46 void DP(int x,int fa){
47 for(int i=fir[x];i;i=nxt[i])
48 if(to[i]!=fa&&!ring[to[i]]){
49 DP(to[i],x);
50 ans=max(ans,dis[x]+dis[to[i]]+val[i]);
51 dis[x]=max(dis[x],dis[to[i]]+val[i]);
52 }
53 }
54
55 int main(){
56 freopen("foodshop.in","r",stdin);
57 freopen("foodshop.out","w",stdout);
58 scanf("%d",&n);
59 for(int i=1,x,y,v;i<=n;i++){
60 scanf("%d%d%d",&x,&y,&v);
61 addedge(x,y,v);addedge(y,x,v);
62 }
63 DFS(1);
64 for(int i=1;i<=top;i++)DP(st[i],0);
65
66 for(int i=1;i<=top;i++){
67 sum+=b[i-1];
68 u1[i]=max(u1[i-1],sum+dis[st[i]]);
69 v1[i]=max(v1[i-1],sum+dis[st[i]]+Mx);
70 Mx=max(Mx,dis[st[i]]-sum);
71 }
72 LL tmp=b[top];Mx=sum=b[top]=0;
73 for(int i=top;i>=1;i--){
74 sum+=b[i];
75 u2[i]=max(u2[i+1],sum+dis[st[i]]);
76 v2[i]=max(v2[i+1],sum+dis[st[i]]+Mx);
77 Mx=max(Mx,dis[st[i]]-sum);
78 }
79 LL Mn=v1[top];
80 for(int i=1;i<top;i++)
81 Mn=min(Mn,max(max(v1[i],v2[i+1]),tmp+u1[i]+u2[i+1]));
82 ans=max(ans,Mn);
83 printf("%.1lf",ans/2.0);
84 return 0;
85 }