比赛 |
20150423 |
评测结果 |
AAAAAAAAAAAAAA |
题目名称 |
奶牛跑步2 |
最终得分 |
100 |
用户昵称 |
Asm.Def |
运行时间 |
0.220 s |
代码语言 |
C++ |
内存使用 |
1.82 MiB |
提交时间 |
2015-04-23 08:57:54 |
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <cmath>
using namespace std;
//#define USEFREAD
#ifdef USEFREAD
#define InputLen 5000000
char *ptr=(char *)malloc(InputLen);
#define getc() (*(ptr++))
#else
#define getc() (getchar())
#endif
#define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
template<class T>inline void getd(T &x){
int ch = getc();bool neg = false;
while(!isdigit(ch) && ch != '-')ch = getc();
if(ch == '-')ch = getc(), neg = true;
x = ch - '0';
while(isdigit(ch = getc()))
x = x * 10 - '0' + ch;
if(neg)x = -x;
}
/***********************************************************************/
const int maxn = 100005;
typedef long long LL;
LL End[maxn], T, Last[maxn];
int N;
inline void init(){
getd(N);getd(T);
int Begin, v;
for(int i = 0;i < N;++i){
getd(Begin), getd(v);
End[i] = T * v + Begin;
}
*Last = 0x7fffffffffffffffll;
}
inline bool cmp(const LL &a, const LL &b){return a > b;}
int main(){
#ifdef DEBUG
freopen("test.txt", "r", stdin);
#else
SetFile(cowjogb);
#endif
#ifdef USEFREAD
fread(ptr,1,InputLen,stdin);
#endif
init();
int i, d, Ans = 0;
for(i = 0;i < N;++i){
d = upper_bound(Last, Last + i + 1, End[i], cmp) - Last;
Ans = max(Ans, d);
Last[d] = End[i];
}
printf("%d\n", Ans);
#ifdef DEBUG
printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
#endif
return 0;
}