Source Code
#include<stdio.h>


int main()
{

    long long n=0;// number of buildings
    long long m=0;// number of people 
    long long heights[100];// height of each building
    long long people[100][2];// building each person is in and floors
    long long maxheight=0;

    scanf("%lld", &n);
    scanf("%lld", &m);

    for(int i=0;i<n;i++){
      scanf("%lld", &heights[i]);
      if(i==0||heights[i]>maxheight){maxheight=heights[i];}
      }//enter heights 

    for(int i=0;i<m;i++){// fill floor and building each person is in
        scanf("%lld", &people[i][0]);
        scanf("%lld", &people[i][1]);
    }
    int counter=0;// number of destroyed floors
    int flag=0;// if flag == 1 there is a person on that floor
for(int i=1;i<=maxheight;i++){
  flag=0;
  for(int j=0;j<m;j++){
    if(people[j][1]==i){flag=1;break;}
    }
  if(flag==1){continue;}

  for(int s=0;s<n;s++){
    if(heights[s]>=i){counter++;}
  }

}
  printf("%d",counter);



}
Copy
Dr. Evil Ayoooy
GNU G++17
27 ms
936 KB
Runtime Error