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

Ended

Participants:506

Verdict:Time Limit Exceeded
Score:30 / 100
Submitted:2016-08-28 13:16:11

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 <stdio.h>  
#include <queue>  
#include<iostream>  
#include <algorithm> 
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <string> 
using namespace std;
struct pic
{
    int w;
    int h;
};
int res_h(vector<pic> pics,int M)
{
    int res=0;
    int len=M;
    int temp_h=0;
    for(int i=0;i<pics.size();i++)
    {
        if(len<pics[i].w)//
        {
            int h=0;
            h=ceil((double)len/(double)(pics[i].w)*(double)(pics[i].h));
            
            temp_h=max(temp_h,h);
            res+=temp_h;
            len=M;
            temp_h=0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX