답안 #403358

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403358 2021-05-13T05:24:41 Z zaneyu 조개 줍기 (KOI17_shell) C++14
12 / 100
2000 ms 28156 KB
/*input
3

3 2 7

4 2 6

5 3 8

U 1 2

D 3 2

U 1 2
*/
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ll long long
const int maxn=2e3+5;
int dp[maxn][maxn];
int arr[maxn][maxn];
int n;
void calc(){
    ll ans=0;
    REP1(i,n){
        REP1(j,n){
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])+arr[i][j];
            ans+=dp[i][j];
        }
    }
    cout<<ans<<'\n';
}
int main(){
    cin>>n;
    REP1(i,n) REP1(j,n) cin>>arr[i][j];
    calc();
    REP(i,n){
        char c;
        int x,y;
        cin>>c>>x>>y;
        if(c=='U') arr[x][y]++;
        else arr[x][y]--;
        calc();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1228 KB Output is correct
2 Correct 8 ms 1172 KB Output is correct
3 Correct 8 ms 1100 KB Output is correct
4 Correct 8 ms 1228 KB Output is correct
5 Correct 8 ms 1228 KB Output is correct
6 Correct 8 ms 1228 KB Output is correct
7 Correct 8 ms 1100 KB Output is correct
8 Correct 8 ms 1100 KB Output is correct
9 Correct 8 ms 1100 KB Output is correct
10 Correct 8 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2082 ms 28156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1228 KB Output is correct
2 Correct 8 ms 1172 KB Output is correct
3 Correct 8 ms 1100 KB Output is correct
4 Correct 8 ms 1228 KB Output is correct
5 Correct 8 ms 1228 KB Output is correct
6 Correct 8 ms 1228 KB Output is correct
7 Correct 8 ms 1100 KB Output is correct
8 Correct 8 ms 1100 KB Output is correct
9 Correct 8 ms 1100 KB Output is correct
10 Execution timed out 2082 ms 28156 KB Time limit exceeded
11 Halted 0 ms 0 KB -