#include iostream#include vector#include algorithmusing namespace std;int main int md; cinmd; vectorint s; int l=0; forint i=0;im;i++ string o; cino; ifo==Q
The code reads two integers m and d from the user, representing the number of queries and the divisor, respectively. It then creates an empty vector s to store the values, and initializes an integer l to 0.
The code then enters a loop that iterates m times. In each iteration, it reads a string o from the user. If o is "Q", it reads an integer L and calculates the maximum element from the subvector of s starting from index max(0, s.size()-L) and ending at the last index. It then prints the maximum element.
If o is "A", it reads an integer n and updates l to (l+n)%d. It then pushes l into the vector s.
Overall, the code implements a simple algorithm to handle two types of queries ("Q" and "A") and perform the corresponding operations based on the input
原文地址: https://www.cveoy.top/t/topic/h6vx 著作权归作者所有。请勿转载和采集!