链接:https://codeforces.com/contest/1136/problem/A
题意:
给n个区间,每个区间范围不超过100,n不超过100。
给一个位置k,1-(k-1)是遍历过的位置,求没有完全遍历完的区间。
k处于区间中时,表示区间没有遍历完
思路:
暴力
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 10;
int a[MAXN];
int main()
{
int n, len = 0;
cin >> n;
for (int i = 1;i <= n;i++)
{
int l, r;
cin >> l >> r;
len = r;
for (int j = l;j <= r;j++)
a[j] = i;
}
int q, res;
cin >> q;
q--;
if (q == len)
cout << 0 << endl;
else
{
res = a[len] - a[q];
if (a[q] == a[q + 1])
res++;
cout << res << endl;
}
return 0;
}