当前位置: 首页> 财经> 股票 > 2022 RoboCom省赛题目解析

2022 RoboCom省赛题目解析

时间:2025/8/27 17:12:12来源:https://blog.csdn.net/2301_79582015/article/details/140363617 浏览次数:0次

题目解析:这就是一题很简单的模拟,直接上代码;

#include<iostream>
using namespace std;
const int N = 10010;
int arr[N];
int main()
{int n , m;cin >> n >> m;int sum = 0;int res = 0;for(int i = 0; i < n;i ++) cin >> arr[i];for(int i = 0;i < n;i ++){if(sum + arr[i] > m){res++;sum = 0;}sum += arr[i];}cout << res << endl;return 0;
}

2.

解析: 这个也是一个很简单的模拟,注意更新他的服药时间

#include<iostream>
using namespace std;
const int N = 10010;
int a[N], last[N];
int main()
{int n, m;cin >> n >> m;for (int i = 1;i <= n; i++){cin >> a[i];last[i] = -100;}int t, k;while (m--){cin >> t >> k;int i;while (k--){cin >> i;if (a[i] == -1) continue;if (t - last[i] >= a[i]) last[i] = t;else{printf("Don't take %d at %d!\n", i, t);}}}return 0;
}

关键字:2022 RoboCom省赛题目解析

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: