Skip to content

Instantly share code, notes, and snippets.

@luciocf
Created April 9, 2019 18:27
Show Gist options
  • Save luciocf/d8c7a2cb914374301cee90adc82a13f5 to your computer and use it in GitHub Desktop.
Save luciocf/d8c7a2cb914374301cee90adc82a13f5 to your computer and use it in GitHub Desktop.
Noic - Iniciante - Semana 50 - Problema 1
// Noic - Iniciante - Semana 50 - Problema 1
// O(n)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int l[maxn], r[maxn];
int main(void)
{
int n, k;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> l[i] >> r[i];
cin >> k;
int ind; // capítulo que contém k
for (int i = 1; i <= n; i++)
if (l[i] <= k && k <= r[i])
ind = i;
cout << n-ind+1 << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment