比赛 20211014 评测结果 WWEEEEEEEW
题目名称 平凡的题面 最终得分 0
用户昵称 张恒畅 运行时间 1.679 s
代码语言 C++ 内存使用 5.08 MiB
提交时间 2021-10-14 19:47:39
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n, m, x, y, num;
int a[100010];
struct node
{
int from, to, z;    
};
node b[100010];
bool cmp(node n1, node n2)
{
  if(n1.to > n2.to)
  return 1; 
  else 
  return 0; 
}
bool cmp2(int x1, int x2)
{
   if(x1 > x2)
   return 1; 
}

int main()
{
    freopen("bg.in","r",stdin);
    freopen("bg.out","w",stdout);
 cin >> n >> m;
 for(int i = 1; i <= n; i++)
 {
   cin >> a[i];  
 }
 for(int i = 1; i <= m; i++)
 {
    cin >> x >> y;
    b[i].from = x;
    b[i].to = y;
    b[i].z = 1;
 }
  sort(b+1, b + 1+ m, cmp); 
//   for(int i = 1; i <= m; i++)
//   cout << b[i].from << "   " << b[i].to<< endl;
   sort(a+1, a+1+n, cmp2);
//   for(int i = 1; i <= n; i++)
//   cout << a[i] <<endl;
   for(int i = 1; i <= n; i++)
   {
   if(a[i] != 0)
    {
    for(int i = 1; i <= m; i++)
     {
      if(a[i] >= b[i].from && a[i] <= b[i].to && b[i].z == 1) 
      {
       a[i] = 0;
       b[i].z = 0;    
       num++;   
      }    
     }    
    }
   }
   cout << num;
   return 0; 
 } 
 /*
 4 4
 2 5 6 9
 5 6
 7 7
 8 10
 1 2
 */