Problem A: Yang Yigo carrying handle time limit:1 Sec Memory limit:128 MB Description
Before the birth of the Sun Wukong, Yang two elder brother has been three of the world, as a carrying handle, not a decent weapon how to do. So two elder brother to Donghalona to oneself and younger brother find weapon. All say local tyrants by equipment, dick Silk by mutation, Yang brothers have such a weapon in the arms of the equipment, the weapons placed in the machine processing, the weight of each weapon (W) and Length (L) has been given, if the transport of the current weapon than the previous weapon of transport length and weight than the previous one, it will not take time, otherwise it takes a minute, Yang Brother's time is very valuable, you need to arrange the order of placement, so that the least time, calculate the number of shipments of n-Weapon of the minimum!
Input
Multiple sets of input data.
Enter N, the number of sticks. n<5000.
Enter W (weight), l (length). 1<w,l<1000000.
Output
The time required for the output.
Sample Input54-432 231 1Sample Output213hint
1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 structnode6 {7 intb;8} a[100001];9 intcmpstructNode A,structNode B)Ten { One if(a.a==B.A) A returna.b<b.b; - returna.a<B.A; - the } - intMain () - { - intN; + while(SCANF ("%d", &n)! =EOF) - { + intans=0, flag[100001]= {0}; A for(intI=0; i<n; i++) atscanf"%d%d",&a[i].a,&a[i].b); -Sort (a,a+n,cmp); - for(intI=0; i<n; i++) - { - if(flag[i]==1) - { in Continue; - } to + for(inti1=i,j=i+1; j<n; J + +) - { the if(a[j].b>=a[i1].b&&flag[j]==0) * { $i1=J;Panax Notoginsengflag[j]=1; - } the } +ans++; A } theprintf"%d\n", ans); + } -}
Yang two elder brother carry the handle