当前位置:网站首页>2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 2: intelligent medication assistant (finished)
2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 2: intelligent medication assistant (finished)
2022-07-24 15:14:00 【trudbot】
subject
RC-u2 Intelligent medication assistant
A very important part of intelligent nursing is to arrange the medication plan of the elderly who need to take medicine .
An elderly person who is known to need care of robots needs to take N Drugs , But some drugs should not be taken at too short intervals —— For example, hypoglycemic drugs are generally taken daily according to the doctor's advice 3 Time , The interval between two times is at least 4 Hours . When you need to take more drugs , When the doctor's order is complex , How to ensure that each elderly person's medication plan is safe and reasonable , Become a challenge .
This question gives a set of medication plan , Please check whether there is any problem with the plan .
Input format :
The first line of input gives two integers N,M(1≤N,M≤1e3), It means that the elderly need to take N Drugs ( The types of drugs range from 1 To N Number ), The corresponding medication plan is M Bar record .
Next, first in a line N Integers separated by spaces Ti(−1≤Ti ≤100,Ti !=0), Indicates that the number is i Drugs need to be separated by at least Ti Take it per unit time . If Ti by −1, It means that there is no interval requirement for this drug .
Next M That's ok , Each line gives a record in the medication plan , The format is : First, give two nonnegative integers t and k (0≤t≤1e9,0≤k≤N),
It means that the time of taking medicine is t, Take it k Drugs ; Then list k Number , Each number corresponds to t The number of the kind of medicine to take at any time . Numbers in a row are separated by spaces .
Title assurance : Record the time of taking medicine t The increasing order of is given ; The kinds of drugs taken at every moment are different . Be careful : The same drug may need to be repeated at different times . If an old man is ti Time and tj Take the same medicine all the time , Then the interval between his taking is |ti-tj|.
Output format :
Check each drug in each record according to the input sequence . If in Y Don't take drugs at all times X, Output in one line :
Don't take X at Y!
Be careful : After receiving the reminder, the elderly will not take the specified drugs according to the reminder .
sample input :
10 6
1 2 3 4 5 -1 -1 -1 -1 -1
0 1 1
1 2 1 2
2 1 2
3 2 1 3
5 3 1 3 4
6 2 1 4
sample output :
Don't take 2 at 2!
Don't take 3 at 5!
Don't take 4 at 6!
Answer key
It is still a simple simulation
Record the time of taking medicine t The increasing order of is given ; The kinds of drugs taken at every moment are different .
This is the key to quickly solve this problem , because t Is increasing , Suppose to judge t Always take i Whether the medicine is reasonable , Just judge t And the last time I took i Whether the time interval of drugs meets the standard
Don't say more nonsense , show you code
AC Code ( Annotated )
//
// Created by trudbot on 2022/7/12.
//
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int tim[N];// Time interval for storing each medicine
int last[N];// The last time I took a drug
int main() {
int n, m;
cin >> n >> m;
for(int i=1; i<=n; i++)
{
cin >> tim[i];
last[i] = -100;// Initialize to a small number , Make sure you can take it for the first time
}
int t, k;
while ( m-- )
{
cin >> t >> k;
int i;
while( k-- )
{
cin >> i;//i For the medicine to be taken at present
if(tim[i] == -1)// No separation requirements , Just skip
continue;
if(t - last[i] >= tim[i])// The interval is big enough , You can take , Update the last taking time to the current time
last[i] = t;
else
printf("Don't take %d at %d!\n", i, t);
}
}
return 0;
}

The above code can AC, Welcome to discuss and exchange any questions
边栏推荐
- 文件操作详解
- DS sort -- quick sort
- The first n rows sorted after dataframe grouping nlargest argmax idmax tail!!!!
- Under multi data source configuration, solve org.apache.ibatis.binding Bindingexception: invalid bound statement (not found) problem
- How vscode debug nodejs
- 佣金哪家券商最低,我要开户,手机上开户安不安全
- [USENIX atc'22] an efficient distributed training framework whale that supports the super large-scale model of heterogeneous GPU clusters
- String application - calculate the longest true prefix of a string
- PrestoUserError: PrestoUserError(type=USER_ERROR, name=INVALID_FUNCTION_ARGUMENT, message=“Escape st
- dataframe 分组后排序的前n行 nlargest argmax idmax tail !!!!
猜你喜欢

Activity Registration: how to quickly start the open source tapdata live data platform on a zero basis?

The accuracy of yolov7 in cracking down on counterfeits, not all papers are authentic

Attributeerror: module 'distutils' has no attribute' version error resolution

DS binary tree - maximum distance of binary tree nodes

Outlook tutorial, how to create tasks and to DOS in outlook?

Huawei wireless device configuration wpa2-802.1x-aes security policy

Existence form and legitimacy of real data in C language (floating point number)

24.原生磁盘的使用
![[USENIX atc'22] an efficient distributed training framework whale that supports the super large-scale model of heterogeneous GPU clusters](/img/dc/be4dc55cdf3085a7b9e58ed6d6a16e.png)
[USENIX atc'22] an efficient distributed training framework whale that supports the super large-scale model of heterogeneous GPU clusters

Operation of MySQL Library
随机推荐
(09) flask is OK if it has hands - cookies and sessions
Meaning of 7 parameters of thread pool
Activate the newly installed Anaconda in the server
Grpc middleware implements grpc call retry
Similarities and differences between nor flash and NAND flash
异或程序
Machine learning practice notes
C# SQLite Database Locked exception
Android section 13 detailed explanation of 03sqlite database
The server switches between different CONDA environments and views various user processes
A common Dao class and util
C# 无操作则退出登陆
Deep learning 1 perceptron and implementation of simple back propagation network
Time series of machine learning
关于构建网络安全知识库方向相关知识的学习和思考
26.文件使用磁盘的代码实现
spark学习笔记(三)——sparkcore基础知识
Performance test - Preparation of test plan
24.原生磁盘的使用
Data analysis and mining 2