#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _WIN64 # include #endif #ifdef _MSC_VER # include # define __builtin_popcount __popcnt # define __builtin_popcountl __popcnt64 #endif using namespace std; #define ll long long #define rep(i, init, n) for(ll i = init; i < (ll)n; i++) #define rrep(i, init, n) for(ll i = init; i >= (ll)n; i--) #define all(x) (x).begin(), (x).end() #define sz(x) (ll)(x.size()) #define Out(x) cout << x << endl #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define Ans cout << ans << endl #define PI 3.14159265358979 #define MOD 998244353 const int inf32 = INT_MAX / 2; const ll inf64 = 1LL << 60; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } templatebool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } // ------------------------------------------------------------------------------------------------- int main() { int n, m; cin >> n >> m; vector a(n + 1); rep(i, 1, n + 1)rep(j, 0, m) { ll v; cin >> v; a[i] += v; } vector dp(n + 1, vector(2, -inf64)); dp[0][0] = 0; rep(i, 1, n + 1) { dp[i] = dp[i - 1]; chmax(dp[i][0], dp[i - 1][1] - a[i]); chmax(dp[i][1], dp[i - 1][0] + a[i]); } Out(dp[n][1]); return 0; }