[题目]B. Ithea Plays With Chtholly [题意]交互题,有n格,每次给一个[1,c]的数字,回答填入的位置后再次给数字,要求在m轮内使n格填满且数列不递减.n,m>=2,1<=c<=1000,1<=n*[c/2]<=m<=1000. [算法]贪心 [题解]对于每次的数字x,找到第一个严格大于的位置替换之(或占一个新的空位置). 这样替换的好处是,不改变当前数列已经满足不递减这一事实的前提下,使数列更优. 那么,每个格子最多被替换c次,总轮数为(…
D - Ithea Plays With Chtholly 思路:考虑每个位置最多被替换c/2次 那么折半考虑,如果小于c/2,从左往右替换,大于c/2总右往左替换,只有小于这个数(从左往右)或者大于这个数(从右往左)才会被替换,所以每个位置最多被替换c/2次. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #defi…
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Are you going to Scarborough Fair? Parsley, sage, rosemary and thyme. Remember me to one who lives there. He on…