Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <string>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- #include <queue>
- #include <cstring>
- #include <set>
- #include <map>
- #include <ctime>
- #include <unordered_map>
- #include <stack>
- using namespace std;
- #define inf 2147483647
- #define eps 0.0000000000001
- #define pi 3.1415926535897932
- #define mod 1000000007
- #define LL long long
- #define ULL unsigned long long
- #define LD long double
- #define ULD unsigned long double
- const int N = 100005;
- // printf("Case #%d: ", ++T);
- // srand(time(NULL));
- // cout<<fixed<<setprecision(3)<<"\nExecution time="<<clock()/1000.0<<endl;
- // freopen("input.txt","r",stdin);
- // freopen("output.txt","w",stdout);
- long long n, m, i, j, k, q, s, w, v, ans;
- long double a[1010][2020];
- long double b[1010][2020];
- long double proc(int i, int j)
- {
- if (i == n + 1)
- return 0;
- if (a[i][j * 2 - 1] == a[i][j * 2])
- return (proc(i + 1, j) + proc(i + 1, j + 1)) / 2 + a[i][j * 2];
- else
- {
- if (a[i][j * 2 - 1] < a[i][j * 2])
- return proc(i + 1, j) + a[i][j * 2 - 1];
- else
- return proc(i + 1, j + 1) + a[i][j * 2];
- }
- }
- int main()
- {
- cin >> w;
- while (w--)
- {
- cin >> n;
- for (i = 1; i <= n; i++)
- for (j = 1; j <= 2 * i; j++)
- cin >> a[i][j];
- cout << fixed << setprecision(7);
- cout<<proc(1, 1)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement