# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403468 | tqbfjotld | 조개 줍기 (KOI17_shell) | C++14 | 2097 ms | 35616 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///subtask
#include <bits/stdc++.h>
using namespace std;
#define int long long
int vals[1505][1505];
int val2[1505][1505];
int num[1505][1505];
main(){
int n;
scanf("%lld",&n);
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
scanf("%lld",&vals[x][y]);
}
}
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
if (x==0){
if (y==0) val2[x][y] = vals[x][y];
else val2[x][y] = vals[x][y]+val2[x][y-1];
}
else if (y==0){
val2[x][y] = vals[x][y]+val2[x-1][y];
}
else{
val2[x][y] = vals[x][y]+max(val2[x-1][y],val2[x][y-1]);
}
}
}
int curans = 0;
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
curans += val2[x][y];
}
}
printf("%lld\n",curans);
for (int x = 0; x<n; x++){
char c;
int a,b;
scanf(" %c%lld%lld",&c,&a,&b);
if (c=='U'){
vals[a-1][b-1]++;
}
else{
vals[a-1][b-1]--;
}
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
if (x==0){
if (y==0) val2[x][y] = vals[x][y];
else val2[x][y] = vals[x][y]+val2[x][y-1];
}
else if (y==0){
val2[x][y] = vals[x][y]+val2[x-1][y];
}
else{
val2[x][y] = vals[x][y]+max(val2[x-1][y],val2[x][y-1]);
}
}
}
int curans = 0;
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
curans += val2[x][y];
}
}
printf("%lld\n",curans);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |