UVA - 12663 |
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <queue>
using namespace std ;
typedef long long LL ;
const int N = 100008 ;
const int inf = 1000000000 ;
int val[N*8] ;
int h[N] ;
int line[N][2] ;
int maxn ;
int cnt[N*8] ;
int main(){
int n , m , K , k , r , l , minl , ca = 1 ;
while(scanf("%d%d%d" , &n , &m , &K) != EOF){
k = 0 ;
for(int i = 1 ; i <= n ; i++){
scanf("%d" , &h[i]) ;
val[k++] = h[i] ;
}
for(int i = 0 ; i < m ; i++){
scanf("%d%d" , &line[i][1] , &line[i][0]) ;
line[i][0]++ ;
val[k++] = line[i][0] ;
val[k++] = line[i][1] ;
}
line[m][0] = 1 ;
line[m][1] = line[m-1][0] ;
val[k++] = line[m][0] ;
val[k++] = line[m][1] ;
sort(val , val+k) ;
for(int i = k -1 ; i > 0 ; i--){
if(val[i] != val[i-1] + 1)
val[k++] = val[i-1] + 1 ;
}
k = unique(val , val+k) - val ;
sort(val , val+k) ;
maxn = k ;
for(int i = 1 ; i <= maxn ; i++) cnt[i] = 0 ;
for(int i = 0 ; i <= m ; i++){
l = lower_bound(val , val+k , line[i][0]) - val + 1 ;
r = lower_bound(val , val+k , line[i][1]) - val + 1 ;
cnt[l]++ ;
cnt[r+1]-- ;
}
cnt[0] = 0 ;
for(int i = 1 ; i <= maxn ; i++) cnt[i] += cnt[i-1] ;
int res = 0 ;
for(int i = 1 ; i <= n ; i++){
l = lower_bound(val , val+k , h[i]) - val + 1 ;
if(cnt[l] >= K) res++ ;
}
printf("Case %d: %d\n" , ca++ , res) ;
}
return 0;
}