记codeforces一个简单模拟题

前天参加的699div2,A题因为没考虑(x,0), (0,y)这种情况没过,b题看了好久最后就写了个读入。后面几个题都没看。。。

今天看了看B题题解,发现一点也不难,就是简地模拟每个石块的滚动就行了。

还是自己太菜了,而且信心不足,打一场比赛就全暴露出来了,没关系慢慢来,我会慢慢厉害的!

B题传送门

AC代码

#include<bits/stdc++.h>
using namespace std;
int t, n, k, ans;
int a[110];
int main()
{
	cin >> t;
	while(t--){
		cin >> n >> k;
		for(int i=0; i<n; ++i) cin >> a[i];
		
		for(int i=1; i<=k; ++i){ // 第i块大石
		    ans = -1;
			for(int j=0; j<n-1; ++j) {
				if(a[j]<a[j+1]) {
					ans = j+1;
					a[j]++;
					break; //下一块石头 
				}
			} 
			if(ans==-1) break;
		}
		cout << ans << "\n";
	}
	return 0;
 } 
posted @ 2021-02-07 11:10  VanHope  阅读(75)  评论(0编辑  收藏  举报