Go: package main

import (
    "bufio"
    "fmt"
    "strconv"
    "os"
    "strings"
    "math"
)

/*
var sc = bufio.NewScanner(os.Stdin) exceed MaxScanTokenSize
func read() string {
    sc.Scan()
    return sc.Text()
}
*/

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func toInt(str string) int {
    n, _ := strconv.Atoi(str)
    return n
}

func min(a int, b int) int {
    return int(math.Min(float64(a), float64(b)))
}

func max(a int, b int) int {
    return int(math.Max(float64(a), float64(b)))
}

func main() {
    nm := strings.Split(readLine(), " ")
    n := toInt(nm[0])
    var infoDist [100000]int
    for i := 0; i < n; i++ {
        infoDist[i] = 100000
    }
    haveInfo := strings.Split(readLine(), " ")
    for _, value := range haveInfo {
        infoDist[toInt(value) - 1] = 0
    }

    for i := 0;i < n - 1; i++ {
        infoDist[i + 1] = min(infoDist[i] + 1, infoDist[i + 1])
    }

    for i := n - 1;i > 0; i-- {
        infoDist[i - 1] = min(infoDist[i] + 1, infoDist[i - 1])
    }

    ans := 0
    for i := 0;i < n;i++ {
        ans = max(ans, infoDist[i])
    }

    fmt.Println(max(ans, infoDist[0]))

}

C++: #include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	long long n,m,a[100000],x[100000];
	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
	}


	for (int j = 0; j < n; j++)
	{
		x[j] = 0;
		for (int i = 0; i < m; i++)
		{
			if (j == a[i] - 1)
			{
				x[j] = 1;
			}
		}
	}

	int gg = 0,dame[100000];
	for (long long j = 0; j < n; j++)
	{
		dame[j] = 0;
	}


	for (long long k = 1; k < 100000; k++)
	{

		for (long long j = 0; j < n; j++)
		{
			if (x[j] == 1 && dame[j] != -1)
			{
				if (j != 0 && j != n - 1)
				{
					if (x[j + 1] == 0)
					{
						x[j + 1] = 1;
						dame[j + 1] = -1;
					}
					if (x[j - 1] == 0)
					{
						x[j - 1] = 1;
						dame[j - 1] = -1;
					}
				}
				else if (j == 0)
				{
					if (x[j + 1] == 0)
					{
						x[j + 1] = 1;
						dame[j + 1] = -1;
					}
				}
				else
				{
					if (x[j - 1] == 0)
					{
						x[j - 1] = 1;
						dame[j - 1] = -1;
					}
				}
			}
		}

		//チェック
		for (long long j = 0; j < n; j++)
		{
			if (x[j] != 1)
			{
				break;
			}
			else if (j == n - 1)
			{
				gg++;
				break;
			}
		}

		if (gg != 0)
		{
			cout << k << endl;
			break;
		}

		for (long long j = 0; j < n; j++)
		{
			dame[j] = 0;
		}
	}
}

C++: #include<iostream>
using namespace std;

int main(){
	int sum;
	while(cin >> sum){
		int number, info[10005], ans;
		cin >> number;
		for(int i = 0; i < number; i++){
			cin >> info[i];
		}
		for(int i = 0; i < number + 1; i++){
			if(!i){
				ans = info[i] - 1;
			}else if(i == number){
				ans = max(ans, sum - info[i - 1]);
			}else{
				int a = (info[i] - info[i - 1]) / 2;
				if(!a) a++;
				ans = max(ans, a);
			}
		}
		cout << ans << endl;
	}
}

C++: https://www.slideshare.net/cocoa_chan/rupc2016-day2-d?qid=1931cae0-cc15-435b-ba12-0e9bc5aeb296&v=&b=&from_search=1

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    cin >> a[0];
    int ma=0;
    for(int i=1;i<m;i++){
        cin >> a[i];
        int tmp = (a[i]-a[i-1])/2;
        ma = max(ma,tmp);
    }
    //cout << ma << endl;
   // cout << a[0]-1 << endl;
    ma = max(ma,n-a[m-1]);
    if(ma <= a[0]-1){
        cout << a[0]-1 << endl;
    }else{
        cout << ma << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

class UnionFind {
public:
  vector<int> par, rank;
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
};

int main(){
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  rep(i,m){
    int s,t;
    cin>>s>>t;
    s--;t--;
    uf.unite(s,t);
  }

  int ans = 0;
  rep(i,n){
    if(uf.size(i)==1) ans++;
    else if(uf.par[i]<0) ans--;
  }
  cout << abs(ans) << endl;

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  rep(i,m) cin>>a[i];

  int ans = max(a[0]-1, n - a.back());
  rep(i,m-1){
    ans = max(ans, (a[i+1] - a[i])/2);
  }
  cout << ans << endl;

  return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
	int sum;
	while(cin >> sum){
		int number, info[100005], ans;
		cin >> number;
		for(int i = 0; i < number; i++){
			cin >> info[i];
		}
		for(int i = 0; i < number + 1; i++){
			if(!i){
				ans = info[i] - 1;
			}else if(i == number){
				ans = max(ans, sum - info[i - 1]);
			}else{
				int a = (info[i] - info[i - 1]) / 2;
				if(!a) a++;
				ans = max(ans, a);
			}
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n, m;
int a[100000];

int main(){
  cin >> n >> m;
  rep(i, m){
    cin >> a[i];
  }
  int ans = max(a[0] - 1, n - a[m - 1]);
  rep(i, m - 1){
    ans = max((a[i + 1] - a[i]) / 2, ans);
  }
  cout << ans << endl;
  return 0;
}