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

Ended

Participants:506

Verdict:Wrong Answer
Score:30 / 100
Submitted:2016-08-28 13:17: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 <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cmath>
using namespace std;
#define INT_MIN     (-2147483647 - 1) /* minimum (signed) int value */
#define INT_MAX       2147483647    /* maximum (signed) int value */
int getMinHeight(int n, const vector<int>& width, const vector<int>& height, int m, int delete_index) {
    
    int current_height = 0;
    int remain_width = n;
    int total_height = 0;
    
    for (int i = 0; i < m; ++i) {
        if (i == delete_index) {
            continue;
        }
        int temp_width = width[i];
        int temp_height = height[i];
        if (temp_width > remain_width) {
            temp_height = ceil(((double)remain_width / temp_width) * (double)temp_height);
            temp_width = remain_width;
        }
        if (temp_height > current_height) {
            current_height = temp_height;
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX