Wooden Sticks.
win the wooden spoon:成为末名。
题目地址:http://poj.org/problem?id=1065
There is a pile of n wooden sticks.
a woodworking machine:木工机器。
setup time:启动时间。
my codes:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int t,n; struct stick { int l,w; }sti[5100]; bool used[5100]; bool cmp(stick a,stick b) { return (a.l<b.l)||(a.l==b.l && a.w<b.w); } int main() { scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d%d",&sti[i].l,&sti[i].w); sort(sti,sti+n,cmp); memset(used,false,sizeof(used)); int ans=0; for(int i=0;i<n;i++) { if(!used[i]) { ans++; int tempW=sti[i].w; for(int j=i+1;j<n;j++) { if(!used[j] && sti[j].w>=tempW) used[j]=true,tempW=sti[j].w; } } } printf("%d\n",ans); } return 0; }
Ref:https://blog.csdn.net/u012278856/article/details/32914859
原文地址:https://www.cnblogs.com/dragondragon/p/11372378.html
时间: 2024-11-08 23:19:04