代码 :
#include <bits/stdc++.h>
using namespace std;
struct zmb{
int p,t;
}a[2005];
bool cmp(const zmb &a,const zmb &b){
if(a.p == b.p) return a.t < b.t;
return a.p < b.p;
}
int n;
int main(){
cin >> n;
for(int i = 0;i < n;i++) cin >> a[i].p >> a[i].t;
sort(a,a + n,cmp);
int j = 0,cnt = 0,last;
for(int i = 1;i <= 6;i++){
if(j == n)break;
last = a[j].t,cnt ++;
while(a[++j].p == i) if(a[j].t - last >= 60)cnt ++,last = a[j].t;
}
cout << cnt;
return 0;
}