Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
模拟/*********************************************** Source Code Problem: 1018 User: zhouzp15 Memory: 844K Time: 110MS Language: G++ Result: Accepted ***********************************************/ #include <iostream> #include <iomanip> #include <cstring> #include <cstdio> #define MAX 0x1f1f1f #define N 110 using namespace std; int MIN, kmin; int T, n, m[N], b[N][N], p[N][N]; int f[500]; double maxbp = -1.0; bool ok[500]; int main() { cin >> T; while (T--) { cin >> n; int Max = -1, Min = MAX; memset (ok, 0, sizeof (ok)); memset (f, 0, sizeof (f)); for (int i = 1; i <= n; i++) { cin >> m[i]; for (int j = 1; j <= m[i]; j++) { cin >> b[i][j] >> p[i][j]; if (b[i][j] > Max) Max = b[i][j]; if (b[i][j] < Min) Min = b[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = Min; j <= Max; j++) { MIN = MAX, kmin = 0; for (int k = 1; k <= m[i]; k++) { if (b[i][k] >= j && p[i][k] < MIN) kmin = k, MIN = p[i][k]; if (b[i][k] == j) ok[j] = true; } if (kmin) f[j] += MIN; else f[j] = MAX; } } maxbp = -1.0; for (int i = Min; i <= Max; i++) if ((double) i / f[i] > maxbp && ok[i]) maxbp = (double)i / f[i]; cout << fixed << setprecision (3) << maxbp << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator