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

Ended

Participants:506

Verdict:Wrong Answer
Score:30 / 100
Submitted:2016-08-28 13:50:03

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 <iostream>
#include <algorithm>
using namespace std;
#define SIZE 100000
int M, N, w[SIZE], h[SIZE];
void init()
{
    pair<int, int> tmp;
    cin >> M >> N;
    for (int i = 0; i < N; ++i)
        cin >> w[i] >> h[i];
}
int getHeight(int sk)
{
    int ans, tw, th;
    ans = tw = th = 0;
    for (int i = 0; i < N; ++i)
    {
        if (i == sk) continue;
        if (tw + w[i] < M)
        {
            tw += w[i];
            th = max(th, h[i]);
        }
        else
        {
            if (tw + w[i] > M)
                th = max(th, (int)ceil(1.0 * (M - tw) / w[i] * h[i]));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX