比赛 |
SBOI2022暑假快乐赛① |
评测结果 |
ATTTTTTTTT |
题目名称 |
Snow Boots |
最终得分 |
10 |
用户昵称 |
cb |
运行时间 |
9.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-06-25 10:19:58 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int N, B;
int f[255], ans[255];
struct node {
int s, d;
}sh[255];
void dfs (int block, int shoe) {
ans[block] = min (ans[block], shoe - 1);
// printf ("block:%d shoe:%d\n", block, shoe);
for (int q = block + 1; q <= block + sh[shoe].d && q <= N; ++q) {
if (f[q] <= sh[shoe].s) {
dfs (q, shoe);
}
}
if (shoe < B) dfs (block, shoe + 1);
}
int main () {
freopen ("snowboots_silver_18feb.in", "r", stdin);
freopen ("snowboots_silver_18feb.out", "w", stdout);
for (int q = 0; q < 255; ++q) {
ans[q] = 251;
}
scanf ("%d %d", &N, &B);
for (int q = 1; q <= N; ++q) {
scanf ("%d", &f[q]);
}
sh[0].s = 0; sh[0].d = 1;
for (int q = 1; q <= B; ++q) {
scanf ("%d %d", &sh[q].s, &sh[q].d);
}
dfs (1, 0);
printf ("%d", ans[N]);
return 0;
}