蒟蒻1AC,2红2黑5紫求调!!

P1803 凌乱的yyy / 线段覆盖

嗯好好好~~把数组调小后~~[不TLE了](https://www.luogu.com.cn/record/139079180),不过7个RE也不行啊o(╥﹏╥)o
by Zskioaert1106 @ 2023-12-10 15:57:32


你可以试下数学归纳法```c #include<iostream> #include<algorithm> using namespace std; int n, ans = 0, finish = 0; struct contest { int l, r; } con[1000010]; bool cmp(contest a, contest b) { return a.r <= b.r; } int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> con[i].l >> con[i].r; sort(con + 1, con + 1 + n, cmp); for (int i = 1; i <= n; i++) if (finish <= con[i].l) ans++, finish = con[i].r; cout << ans << endl; return 0; } ```
by 71425wsf @ 2023-12-19 22:27:00


|