洛谷P8572
#include<bits/stdc++.h>
using namespace std;
#define int long long
int c[705][705];
signed main()
{int n, k, q;cin >> n >> k >> q;//int a[n + 1][k + 1];vector<vector<int>> a(k + 1, vector<int>(n + 1));for (int i = 1; i <= k;i++)for (int j = 1; j <= n;j++){int x;cin >> x;a[i][j] = a[i][j - 1] + x;}if(n<=700){for (int i = 1; i <= k;i++)for (int j = 1; j <= n;j++)for (int p = 1; p <= n;p++)c[j][p] = max(c[j][p], a[i][p] - a[i][j - 1]);while(q--){int l, r;cin >> l >> r;cout << c[l][r] << endl;}return 0;} while(q--){int l, r, mx = 0;cin>>l>>r;for (int i = 1; i <= k;i++)mx = max(mx, a[i][r] - a[i][l - 1]);cout << mx << endl;}}