比赛 |
平凡的题目 |
评测结果 |
AAAAAAAAAA |
题目名称 |
平凡的题面 |
最终得分 |
100 |
用户昵称 |
璞瑞 |
运行时间 |
0.385 s |
代码语言 |
C++ |
内存使用 |
2.69 MiB |
提交时间 |
2015-11-03 10:12:32 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void mint(T& a, T b) { if (a > b) a = b; }
template <class T> inline void maxt(T& a, T b) { if (a < b) a = b; }
const int maxn = 100333;
int n, m, A[maxn];
vector<pair<int, int> > dl[maxn], dr[maxn];
int main()
{
freopen("bg.in", "r", stdin);
#ifndef debug
freopen("bg.out", "w", stdout);
#endif
scanf("%d%d", &n, &m); int d = 0;
for (int i = 0; i < n; ++i)
{
int x; scanf("%d", &x);
++A[x]; maxt(d, x);
}
for (int i = 0; i < m; ++i)
{
int l, r; scanf("%d%d", &l, &r);
dl[l].push_back(make_pair(l, r));
dr[r].push_back(make_pair(l, r));
}
multiset<pair<int, int> > S;
int ans = 0;
for (int i = 0; i <= d; ++i)
{
for (vector<pair<int, int> >::iterator p = dl[i].begin();
p != dl[i].end(); ++p) S.insert(make_pair(p->second, p->first));
while (A[i] --> 0)
{
multiset<pair<int, int> >::iterator p = S.lower_bound(make_pair(i, 0));
if (p != S.end()) S.erase(p), ++ans;
else break;
}
for (vector<pair<int, int> >::iterator p = dr[i].begin();
p != dr[i].end(); ++p) S.erase(make_pair(p->second, p->first));
}
printf("%d\n", ans);
}