标签:
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 910 Accepted Submission(s):
295
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 100001; struct Posi{ double x, y; }Num[N]; bool cmp(Posi x, Posi y){ return x.x < y.x; } int main(){ int T; while(~scanf("%d", &T), T){ for(int i = 0; i < T; i++) scanf("%lf%lf", &Num[i].x, &Num[i].y); double tana, tanb; scanf("%lf/%lf", &tana, &tanb); sort(Num, Num+T, cmp); //按位置排一下序。 double Max = Num[0].y; int sum = 0; for(int i = 1; i < T; i++){ if(Max-Num[i].y-(Num[i].x-Num[i-1].x)*tana/tanb >= 0){ //更新Max值及计算被挡木条数目; sum++; Max = Max - (Num[i].x-Num[i-1].x)*tana/tanb; } else Max = Num[i].y; } printf("%d\n", T-sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4915304.html