#include #define in cin #define out cout #define MAXN 1001 using namespace std; ifstream f("data.in"); int n; int d; int m; int len[MAXN]; int nr[MAXN]; pair content[MAXN]; bool removed[MAXN]; pair leaves[MAXN]; int days[MAXN]; void read() { in >> d; in >> n; in >> m; for (int i = 1; i <= n; i++) { in >> days[i]; } for (int i = 1; i <= m; i++) in >> leaves[i].first, in >> leaves[i].second; } void solve() { sort(days + 1, days + n + 1); sort(leaves + 1, leaves + m + 1); for (int i = 1; i <= m; i++) { for (int j = 1; j <= m; j++) { if (days[j] > leaves[i].second) break; if (days[j] >= leaves[i].first) { if (content[i].first == 0) content[i].first = j; content[i].second = j; } } } sort(content + 1, content + m + 1); int maxLen = 0; int sol = m; for (int i = 1; i <= m; i++) { len[i] = content[i].second - content[i].first + 1; nr[i] = 1; if (len[i] == n) { out << 1 << '\n'; return; } for (int j = 1; j < i; j++) { if (content[j].second == content[i].first - 1) { if (len[i] < len[j] + content[i].second - content[i].first + 1) { len[i] = len[j] + content[i].second - content[i].first + 1; nr[i] = nr[j] + 1; } } else if (content[j].second > content[i].first) { if (len[i] < len[j] + content[i].second - content[i].first + 1 - (content[j].second - content[i].first + 1)) { len[i] = len[j] + content[i].second - content[i].first + 1 - (content[j].second - content[i].first + 1); nr[i] = nr[j] + 1; } } } if (len[i] == n) { sol = min(nr[i], sol); } } cout << sol << '\n'; } int main() { read(); solve(); return 0; }