比赛 |
平凡的题目 |
评测结果 |
WWWWWWWWWW |
题目名称 |
平凡的题面 |
最终得分 |
0 |
用户昵称 |
pppoooiiizzy |
运行时间 |
1.868 s |
代码语言 |
C++ |
内存使用 |
1.46 MiB |
提交时间 |
2015-11-03 08:42:57 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<stack>
const int maxn = 100000 + 5;
using namespace std;
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define drep(i, j, k) for(int i = j; i >= k; i--)
#define INF 0x3fffffff
#define LL long long
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
return x * f;
}
struct point {
int L, R;
}a[maxn];
multiset<int>s;
int m, n, Ar, Sa, cnt, ans, tot, b1, b2;
int vis[maxn];
/*
bool cmp(const point i, const point j) {
if(i.L != j.L) return i.L < j.L;
else return i.R < j.R;
}*/
bool cmp(const point i, const point j) {
return i.R - i.L < j.R - j.L;
}
void init()
{
n = read(), m = read();
rep(i, 1, n) {Ar = read(); b1 = min(b1, Ar); s.insert(Ar);}
rep(i, 1, m) a[i].L = read(), a[i].R = read();
}
void print()
{
rep(i, 1, m) { cout<<a[i].L<<" "<<a[i].R<<endl; }
}
int main()
{
freopen("bg.in", "r", stdin);
freopen("bg.out", "w", stdout);
init();
sort(a + 1, a + 1 + m, cmp);
set<int>::iterator it;
rep(i, 1, m) {
rep(j, a[i].L, a[i].R)
if(s.count(j)) {
ans++, s.erase(j);
break;
}
}
cout<<ans<<endl;
}