#include <algorithm> #include <cstdio> #include <vector> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define VAR(v,w) __typeof(w) v=(w) #define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define PB push_back #define SIZE(c) ((int)(c).size()) #define INT(x) int x; scanf("%d", &x) typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; VVLL v; int main() { INT(n); v.resize(n); REP(i,n) { INT(k); v[i].resize(k); REP(j,k) scanf("%lld", &v[i][j]); } LL res = 8000000000000000000LL; FORE(it,v) { int k = SIZE(*it); it->PB((*it)[0]); it->PB((*it)[1]); REP(j,k) res = min(res, abs((*it)[j] - (*it)[j + 2]) - 2); } res = max(res, 0LL); res >>= 1; printf("%lld\n", res); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <algorithm> #include <cstdio> #include <vector> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define VAR(v,w) __typeof(w) v=(w) #define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define PB push_back #define SIZE(c) ((int)(c).size()) #define INT(x) int x; scanf("%d", &x) typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; VVLL v; int main() { INT(n); v.resize(n); REP(i,n) { INT(k); v[i].resize(k); REP(j,k) scanf("%lld", &v[i][j]); } LL res = 8000000000000000000LL; FORE(it,v) { int k = SIZE(*it); it->PB((*it)[0]); it->PB((*it)[1]); REP(j,k) res = min(res, abs((*it)[j] - (*it)[j + 2]) - 2); } res = max(res, 0LL); res >>= 1; printf("%lld\n", res); } |