Two-point answer.
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace STD; #define REP (i,n) for (int i=1;i<=n;i++) const int inf=0x7f7f7f7f;int c[55],n,m;bool Check (int x) {int cnt=min (X,M); Rep (i,n) if (c[i]<x) {cnt-=x-c[i];if (cnt<0) return false;} return true;} void work () {int L=0,r=inf,ans;while (l<=r) {int mid= (l+r) >>1;if (check (mid)) Ans=mid,l=mid+1;else R=mid-1;} printf ("%d\n", ans);} int main () {; scanf ("%d%d", &n,&m), Rep (i,n) scanf ("%d", &c[i]); work (); return 0;}
1816: [Cqoi2010] Poker time limit:10 Sec Memory limit:64 MB
submit:1784 solved:704
[Submit] [Status] [Discuss] Description you have n kinds of cards, the number of the first type of cards is CI. There is also a special card: Joker, the number of which is M. You can use each of the cards to form a set of cards, you can also use a joker and other than a certain card to form a card each 1 sets of cards. For example, when n=3, there are 4 kinds of legitimate decks: {A-j,2,3}, {1,j,3}, {1,2,j}. Given n, m and CI, your task is to compose as many decks as possible. Each card can only be used in a set of cards (you may not use the card). The first line of input contains two integers n, m, the number of species and joker of the card. The second line contains n integer ci, which is the number of cards per card. Output outputs only one integer, which is the maximum number of decks that are composed. Sample Input3 4
1 2 3Sample Output3
Sample explanation
The input data indicate: There are 1 1, 2 2, 3 3, 4 joker. You can compose up to third officer decks: {1,j,3}, {j,2,3}, {J,2,3},joker has one remaining, and the rest of the cards run out.
Data range
50% data satisfies: 2 < = N < = 5, 0 < = m < = 10^ 6, 0< = ci < = 200
100% of the data meet: 2 < = n < =, 0 < = m, ci < = 500,000,000.
HINT Source [Submit] [Status] [Discuss]
bzoj1816: [Cqoi2010] Poker