This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll arr[1515][1515];
ll dp[1515][1515];
ll get(){
ll ret = 0;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + arr[i][j];
ret += dp[i][j];
}
}
return ret;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
cin >> arr[i][j];
}
}
cout << get() << "\n";
for(int i=1; i<=n; i++){
char op; int a, b;
cin >> op >> a >> b;
if(op == 'U') arr[a][b]++;
else arr[a][b]--;
cout << get() << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |