首页 > 其他 > 详细

【Educational Codeforces Round 37 A】 Water The Garden

时间:2018-02-03 15:16:14      阅读:258      评论:0      收藏:0      [点我收藏+]

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


在这里输入题意

【题解】


记录下水龙头在哪些位置。
然后每秒钟把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;
}

【Educational Codeforces Round 37 A】 Water The Garden

原文:https://www.cnblogs.com/AWCXV/p/8408715.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!