P12244 踩点
因为只用考虑下课,所以只用看
AC Code
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
#define maxn 10010
#define mod 1e9 + 7
#define upto(i, a, b) for (int i = a; i <= b; i++)
#define downto(i, a, b) for (int i = a; i >= b; i--)
#define rep(i, a, b) for (int i = a; i < b; i++)
int main()
{
int n, t, end = 0;
int tot = 0;//打球的总时间
cin >> n >> t;
int start[N], end[N];
upto(i, 1, n)
{
cin >> start[i] >> end[i];
}
upto(i, 1, n)
{
if (i > 1)//不用看start[1]
{
int jian = start[i] - end[i - 1];
if (jian > t)//只要不迟到
{
tot += (jian - t);
}
}
}
cout << tot;
return 0;
}