记录编号 159936 评测结果 AAAAAAAAAAAAAA
题目名称 奶牛跑步2 最终得分 100
用户昵称 GravatarAsm.Def 是否通过 通过
代码语言 C++ 运行时间 0.217 s
提交时间 2015-04-23 12:16:17 内存使用 1.82 MiB
显示代码纯文本
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <cctype>
  6. #include <algorithm>
  7. #include <cmath>
  8. using namespace std;
  9. //#define USEFREAD
  10. #ifdef USEFREAD
  11. #define InputLen 5000000
  12. char *ptr=(char *)malloc(InputLen);
  13. #define getc() (*(ptr++))
  14. #else
  15. #define getc() (getchar())
  16. #endif
  17. #define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
  18. template<class T>inline void getd(T &x){
  19. int ch = getc();bool neg = false;
  20. while(!isdigit(ch) && ch != '-')ch = getc();
  21. if(ch == '-')ch = getc(), neg = true;
  22. x = ch - '0';
  23. while(isdigit(ch = getc()))
  24. x = x * 10 - '0' + ch;
  25. if(neg)x = -x;
  26. }
  27. /***********************************************************************/
  28. const int maxn = 100005;
  29. typedef long long LL;
  30. LL End[maxn], T, Last[maxn];
  31. int N;
  32.  
  33. inline void init(){
  34. getd(N);getd(T);
  35. int Begin, v;
  36. for(int i = 0;i < N;++i){
  37. getd(Begin), getd(v);
  38. End[i] = T * v + Begin;
  39. }
  40. *Last = 0x7fffffffffffffffll;
  41. }
  42.  
  43. inline bool cmp(const LL &a, const LL &b){return a > b;}
  44.  
  45. int main(){
  46. #ifdef DEBUG
  47. freopen("test.txt", "r", stdin);
  48. #else
  49. SetFile(cowjogb);
  50. #endif
  51. #ifdef USEFREAD
  52. fread(ptr,1,InputLen,stdin);
  53. #endif
  54. init();
  55. int i, d, Ans = 0;
  56. for(i = 0;i < N;++i){
  57. d = upper_bound(Last, Last + Ans + 1, End[i], cmp) - Last;
  58. Ans = max(Ans, d);
  59. Last[d] = End[i];
  60. }
  61. printf("%d\n", Ans);
  62. #ifdef DEBUG
  63. printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
  64. #endif
  65. return 0;
  66. }