随笔 - 530  文章 - 0  评论 - 3  阅读 - 10098 

随笔分类 -  贪心

1~n 线段覆盖
摘要:void solve(){ int r=a[1].r; int i=2, mx=0, ans=1; while(r<len){ mx=r; while(a[i].l<=r&&i<=len){ mx=max(mx,a[i].r); i++; } ans++ ; r=mx; } cout<<ans-1< 阅读全文
posted @ 2023-06-30 23:53 towboat 阅读(6) 评论(0) 推荐(0) 编辑
一本通1424: 区间覆盖
摘要:给一些区间,挑出最少的区间覆盖 【0,L】 贪心:从0往后,每次挑出R 点最大的 #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std ; const int 阅读全文
posted @ 2023-02-27 18:26 towboat 阅读(27) 评论(0) 推荐(0) 编辑
cf1731A
摘要:题目 略 简单的贪心 #include <iostream> #include <cstring> using namespace std; const int N=2003; int n,k,len; int c[30]; char s[N]; int main(){ int cas; cin>> 阅读全文
posted @ 2022-10-08 09:15 towboat 阅读(11) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示