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 |
WA了,谁帮忙看看 !#include <iostream> #include <fstream> const int N = 100010; using namespace std; int n, k, a[N]; int attempt (int l, int r) { int i, b, t, s; int tmp; if (l < r) { s = 0; t = (l + r) / 2; for (i = 0; i < n; i ++) { tmp = a[i]; tmp -= t; if (tmp > 0) { s += (tmp + k - 2) / (k - 1); } } if (s <= t) { b = attempt (l, t); } else { b = attempt (t + 1, r); } return b; } else { return r; } } void solve () { int i, tmp; for (tmp = 0, i = 0; i < n; i ++) { scanf ("%d", &a[i]); if (a[i] > tmp) { tmp = a[i]; } } scanf ("%d", &k); if (k > 1) { printf ("%d\n", attempt (1, tmp)); } else { printf ("%d\n", tmp); } } int main () { while (EOF != scanf ("%d", &n)) { solve (); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator