USACO 2014 Dec Silver 3.Cow Jog

2015.03.04 11:16 Wed| 9 visits oi_2015| 2015_刷题日常| Text

Solution

Input/Output 这个标签的意思是水到只剩下读入和输出 -_-||

Code

#include <bits/stdc++.h>
using namespace std;
#define N 100005

long long n, t, x, y;
stack<long long> cow;

int main()
{
    cin >> n >> t;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x >> y;
        while (!cow.empty() && x + t * y <= cow.top())
            cow.pop();
        cow.push(x + t * y);
    }
    cout << cow.size() << endl;
}