Wooden Sticks (模拟)

还是感觉蛮神奇的,用sort函数对木棍的两个属性进行排列,然后用了一个标记数组。
题目大意:
给你一堆木棒,每个木棒都有自己的长度和重量,装一个木棒需要一分钟,如果下一个木棒的长度和重量均小于这个,那接下来的这个就不需要花费时间,问最少需要花多久……

题目链接: 点击打开链接

代码:
#include
#include
#include
#include

using namespace std;
int vis[5500];
struct node
{
    int len;
    int weight;
}e[5500];

int cmp(struct node a,struct node b)    //排序
{
    if(a.len!=b.len)
        return a.len=maxwei)
                    {
                        vis[j]=1;
                        maxwei=e[j].weight;
                    }
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

你可能感兴趣的:(Wooden Sticks (模拟))