Bi的范围比1000大,改成5000就过了。
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
#define maxn 3111
struct node {
double l, r;
}p[maxn];
int n;
bool vis[maxn];
int main () {
while (cin >> n && n) {
for (int i = 1; i <= n; i++) {
cin >> p[i].l >> p[i].r;
if (p[i].r > 5000) while (1) {}
}
int ans = 0;
for (double i = 0.5; i <= 5; i += 1.0) {
memset (vis, 0, sizeof vis);
int cur = 0;
for (double t = i; t <= 5000; t += 5) {
int pos;
double Min = 111111;
for (int j = 1; j <= n; j++) {
if (p[j].l < t && p[j].r > t && p[j].r < Min && !vis[j]) {
Min = p[j].r;
pos = j;
}
}
if (Min < 111111) {
vis[pos] = 1;
cur++;
}
}
ans = max (ans, cur);
}
cout << ans << endl;
}
return 0;
}