1. 程式人生 > >【Educational Codeforces Round 37 A】 Water The Garden

【Educational Codeforces Round 37 A】 Water The Garden

define 記錄 const log body ace test ret href

【鏈接】 我是鏈接,點我呀:)
【題意】


在這裏輸入題意

【題解】


記錄下水龍頭在哪些位置。
然後每秒鐘把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