【Educational Codeforces Round 37 A】 Water The Garden

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

记录下水龙头在哪些位置。 然后每秒钟把index-i和index+i改变状态一下就好(置1

【代码】

#include <bits/stdc++.h>
using namespace std;

const int N = 200;

int n,k;
int a[N+10],x[N+10];

int ok(){
    for (int i = 1;i <= n;i++)
        if (a[i]==0) return 0;
    return 1;
}

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
    int T;
    cin >> T;
    while (T--){
        memset(a,0,sizeof a);
        cin >> n >> k;
        for (int i = 1;i <= k;i++){
            cin >> x[i];
        }
        int num = 0;
        while (!ok()){
            for (int i = 1;i <= k;i++){
                a[max(1,x[i]-num)]=1;
                a[min(n,x[i]+num)]=1;
            }
            num++;
        }
        cout<<num<<endl;
    }
	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/8408715.html