[Offer收割]编程练习赛1 register

Ended

Participants:955

Verdict:Accepted
Score:100 / 100
Submitted:2016-03-06 16:51:34

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
#define x first 
#define y second
const int maxt=1000+5;
int n, m, t, s;
int a[5][5], b[maxt], c[maxt], cnt, atk[1<<16|1];
typedef pair<int,int> pii;
pii A[25];
bool No()
{
    cnt=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) A[cnt++]={a[i][j],i};
    sort(A,A+cnt,greater<pii>());
    int sum=0;
//  cnt=min(cnt,t);
    for(int i=0;i<cnt;i++) sum+=A[i].x*b[i];
    return sum<s;
}
int solve(int x)
{
    int sum=0, atk=0;
    for(int i=0, B=0, C=0;i<cnt;i++, x>>=1)
        if(x&1)
        {
            if(!c[C]) return -1;
            atk+=c[C++]*A[i].x;
        }
        else sum+=b[B++]*A[i].x;
    return sum<s ? -1 : atk;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX