T1
Zzx2013
·
·
个人记录
#include<bits/stdc++.h>
using namespace std;
const int N = 3010;
const int inf = 0x3f3f3f3f;
int n, m, f[N];
struct Node{
int l, r;
}no[N];
bool vis[N];//初始状态
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("spring.in", "r", stdin);
freopen("spring.out", "w", stdout);
cin >> n >> m;
for(int i = 1; i <= n; ++i){
cin >> no[i].l >> no[i].r;
for(int j = no[i].l; j <= no[i].r; ++j){
vis[j] = true;
}
}
memset(f, inf, sizeof(f));
n += 2;
no[n - 1] = {0, 0};
no[n] = {m + 1, m + 1};
f[0] = 0;
for(int i = 1; i <= m; ++i){//哪个点
if(vis[i]){
f[i] = f[i - 1];
continue;
}
for(int j = 1; j <= n; ++j){//使用哪个弹簧
if(no[j].r < i){//从左边扩展
int more = i - no[j].r;
if(no[j].l - more - 1 < 1) f[i] = min(f[i], more);
else f[i] = min(f[i], f[no[j].l - more - 1] + more);
// cout << i << " " << j << " " << f[i] << " " << more << endl;
}
}
}
cout << f[m] << endl;
return 0;
}/*
T1 spring 超级弹簧
考虑f[i]表示覆盖i最少使用的次数
到一个点时枚举所有弹簧覆盖
n<=3000...
按左端点排序后贪心 不对 一定用最近的吗 - 事实上不一定
中英一定要互译
-----------2026年NOICA联盟-NOIP模拟赛(十七)-DIV2----------
8:05 不是下发文件炸了只能用Div1的了
8:29 T2搞定了,但没有大样例,再说
8:41 T3有点思路但不确定正确性,先开T4
8:45 不是现在大样例上去了...等一会测一下T2吧
9:10 T1思路很巧妙,这是怎么想到的
9:28 T2没取模气笑了
9:29 T2没毛病li(喜)
9:59 T3 OK了,兵贵神速啊 验证一下复杂度 时间没问题
11:04 T4答案稍小,祭
11:21 T4极限数据跑了10s,气死我了,不过至少得到72pts了,好耶
11:43 T4优化到6.3s了,就差一点(bushi) 5.7s了
预计分数: 100 + 100 + 100 + 72 = 372
*/