constint maxn = 10005; int x[maxn]; int y[maxn]; int newx[maxn]; int n;
intmain() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; } sort(x + 1, x + n + 1); for (int i = 1; i <= n; i++) newx[i] = x[i] - i + 1; sort(newx + 1, newx + n + 1); sort(y + 1, y + n + 1); int x0 = newx[n / 2 + 1]; int y0 = y[n / 2 + 1]; int res = 0; for (int i = 1; i <= n; i++) { res += abs(y[i] - y0); res += abs(newx[i] - x0); } cout << res << endl; return0; }
constint maxn = 1005; constint maxm = 10005; int t[maxm]; int x[maxm]; int y[maxm]; int dp[maxm];
intmain() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) cin >> t[i] >> x[i] >> y[i]; for (int i = 0; i < m; i++) dp[i] = 1; for (int i = 1; i < m; i++) { for (int j = 0; j < i; j++) { if (abs(t[i] - t[j]) >= abs(x[i] - x[j]) + abs(y[i] - y[j])) { dp[i] = max(dp[i], dp[j] + 1); } } }
int ans = 0; for (int i = 0; i < m; i++) ans = max(ans, dp[i]); cout << ans; return0; }