1 /**************************************************************
2 Problem: 3130
3 User: Doggu
4 Language: C++
5 Result: Accepted
6 Time:84 ms
7 Memory:872 kb
8 ****************************************************************/
9
10 #include <cstdio>
11 #include <cstring>
12 #include <algorithm>
13 using namespace std;
14 template<class T>inline void readin(T &res) {
15 static char ch;
16 while((ch=getchar())<‘0‘||ch>‘9‘);
17 res=ch-48;while((ch=getchar())>=‘0‘&&ch<=‘9‘)res=(res<<1)+(res<<3)+ch-48;
18 }
19
20 const int N = 110;
21 const int M = 2010;
22 const double eps = 1e-6;
23 struct Edge{int v,upre;double cap,flow;}g[M];
24 int head[N], ne=-1;
25 inline void adde(int u,int v,double cap) {
26 g[++ne]=(Edge){v,head[u],cap,0},head[u]=ne;
27 g[++ne]=(Edge){u,head[v],0,0},head[v]=ne;
28 }
29
30 int n, m, s, t, p, ok;
31 int q[N], front, rear, d[N], cur[N];
32 bool BFS(double Bound) {
33 memset(d, 0,sizeof(d));
34 front=rear=0;d[s]=1;q[rear++]=s;
35 while(front!=rear) {
36 int u=q[front++];
37 for( int i = head[u]; i!=-1; i = g[i].upre ) {
38 int v=g[i].v;if(ok) g[i].flow=0,g[i^1].flow=0;
39 if(!d[v]&&min(Bound,g[i].cap)>g[i].flow+eps) d[v]=d[u]+1,q[rear++]=v;
40 }
41 }
42 ok=0;
43 return d[t]>0?1:0;
44 }
45 double DFS(int u,double a,double Bound) {
46 if(u==t||a==0) return a;
47 double flow=0, f;
48 for( int &i = cur[u]; i!=-1; i = g[i].upre ) {
49 int v=g[i].v;
50 if(d[v]==d[u]+1&&(f=DFS(v,min(a,min(Bound,g[i].cap)-g[i].flow),Bound))>eps) {
51 flow+=f;a-=f;g[i].flow+=f;g[i^1].flow-=f;
52 if(a==0) return flow;
53 }
54 }
55 if(!flow) d[u]=0;
56 return flow;
57 }
58 double maxflow(double Bound) {
59 double flow=0;
60 while(BFS(Bound)) {
61 memcpy(cur, head,sizeof(head));
62 flow+=DFS(s,0x3f3f3f3f,Bound);
63 }
64 return flow;
65 }
66
67 int main() {
68 memset(head, -1,sizeof(head));
69 readin(n);readin(m);readin(p);
70 double CMP, lf=0, rg=0;
71 for( int i = 1; i <= m; i++ ) {
72 int u, v;double cap;
73 readin(u);readin(v);scanf("%lf",&cap);
74 rg=max(rg,cap);
75 adde(u,v,cap);
76 }
77 s=1;t=n;
78 CMP=maxflow(0x3f3f3f3f);
79 while(lf+eps<rg) {
80 double mid=(lf+rg)/2;
81 ok=1;double tmp=maxflow(mid);
82 if(tmp<CMP) lf=mid;
83 else rg=mid;
84 }
85 printf("%.lf\n%.4lf\n",CMP,lf*p);
86 return 0;
87 }