#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 103, K = 10;
int T, n;
struct people {
int t;
int k;
int a[K], b[K];
bool f[K];
int waittime; // 开始等待的时间
} p[N];
int book[K];
int ans;
bool cmp(people x, people y) {
if (x.waittime == y.waittime) return (x.t < y.t);
return (x.waittime < y.waittime);
}
int main(void) {
ios::sync_with_stdio(false);
cin >> T >> n;
for (int i = 1; i <= n; ++i) {
cin >> p[i].t;
cin >> p[i].k;
for (int j = 1; j <= p[i].k; ++j) {
p[i].f[j] = false;
cin >> p[i].a[j] >> p[i].b[j];
}
p[i].waittime = p[i].t;
}
for (int i = 0; i <= T; ++i) {
sort(p + 1, p + n + 1, cmp);
for (int j = 1; j <= n; ++j) {
if (p[j].t > i || p[j].waittime > i) continue;
for (int l = 1; l <= p[j].k; ++l) {
if (book[p[j].a[l]] <= i && p[j].f[l] == false) {
p[j].f[l] = true;
p[j].waittime = book[p[j].a[l]] = i + p[j].b[l];
++ans;
break;
}
}
}
}
cout << ans;
return 0;
}
此题 70pts。 为什么将每个人进入时间 +1 后就能变成 90pts? 然后为什么还 WA 了一个点?
Help!!!