#include using namespace std; #define x first #define y second #define pb push_back #define eb emplace_back #define rep(i,a,b) for(auto i = (a); i != (b); ++i) #define REP(i,n) rep(i,0,n) #define all(v) (v).begin(), (v).end() typedef long long ll; typedef long double ld; typedef pair ii; typedef vector vi; typedef vector vvi; typedef vector vii; const int maxn = 1e6; int N, M, C[maxn], D[maxn] = {}; vi E[maxn]; ld DP[maxn] = {}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N >> M; REP(i, N) cin >> C[i]; REP(i, M) { int s, t; cin >> s >> t; E[t].pb(s); D[s]++; } queue q; REP(i, N) if (D[i] == 0) q.push(i); while (!q.empty()) { int cur = q.front(); q.pop(); // find the best // Variant 1: you have to pick the current pizza: //DP[cur] = ((ld) 0.5) * DP[cur] + C[cur]; // cerr << "DP[" << cur << "] = " << DP[cur] << endl; // Variant 2: you can choose to pick the current pizza: DP[cur] = max(DP[cur], ((ld) 0.5) * DP[cur] + C[cur]); for (int nxt : E[cur]) { assert(D[nxt] > 0); DP[nxt] = max(DP[nxt], DP[cur]); if (--D[nxt] == 0) { q.push(nxt); } } } ld answer = DP[0]; (cout << fixed).precision(15); cout << answer << endl; return 0; }