답안 #37922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37922 2017-12-29T03:36:30 Z Talant UFO (IZhO14_ufo) C++14
35 / 100
2000 ms 9708 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e6 + 7;

int n,m,r,k,p;
int mx = 0;

int main () {
        cin >> n >> m >> r >> k >> p;

        int a[n + 1][m + 1];

        for (int i = 1; i <= n; i ++)
                for (int j = 1; j <= m; j ++)
                        cin >> a[i][j];

        while (k --) {
                char ch;
                int l,bl,cnt = 0;
                cin >> ch >> l >> bl;

                if (ch == 'N') {
                        cnt = 0;
                        for (int i = 1; i <= n; i ++) {
                                if (a[i][l] >= bl)
                                        a[i][l] --,cnt ++;
                                if (cnt == r)
                                        break;
                        }
                }
                else if (ch == 'W') {
                        cnt = 0;
                        for (int i = 1; i <= m; i ++) {
                                if (a[l][i] >= bl)
                                        a[l][i] --,cnt ++;
                                if (cnt == r)
                                        break;
                        }
                }
                else if (ch == 'E') {
                        cnt = 0;
                        for (int i = m; i >= 1; i --) {
                                if (a[l][i] >= bl)
                                        a[l][i] --,cnt ++;
                                if (cnt == r)
                                        break;
                        }
                }
                else {
                        cnt = 0;
                        for (int i = n; i >= 1; i --) {
                                if (a[i][l] >= bl)
                                        a[i][l] --,cnt ++;
                                if (cnt == r)
                                        break;
                        }
                }
        }
        for (int i = 1; i <= n; i ++)
                for (int j = 2; j <= m; j ++)
                        a[i][j] += a[i][j - 1];

        for (int i = 2; i <= n; i ++)
                for (int j = 1; j <= m; j ++)
                        a[i][j] += a[i - 1][j];

        for (int i = 1; i <= n; i ++)
                a[i][0] = 0;
        for (int j = 0; j <= m; j ++)
                a[0][j] = 0;

        for (int i = p; i <= n; i ++)
                for (int j = p; j <= m; j ++) {
                        mx = max(mx,a[i][j] - a[i - p][j] - a[i][j - p] + a[i - p][j - p]);
                }

        cout << mx << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 13 ms 2016 KB Output is correct
5 Correct 49 ms 2108 KB Output is correct
6 Correct 249 ms 3812 KB Output is correct
7 Execution timed out 2000 ms 6192 KB Execution timed out
8 Execution timed out 2000 ms 6188 KB Execution timed out
9 Execution timed out 2000 ms 5988 KB Execution timed out
10 Execution timed out 2000 ms 6184 KB Execution timed out
11 Execution timed out 2000 ms 6112 KB Execution timed out
12 Execution timed out 2000 ms 6192 KB Execution timed out
13 Execution timed out 2000 ms 6188 KB Execution timed out
14 Correct 1683 ms 6112 KB Output is correct
15 Execution timed out 2000 ms 6192 KB Execution timed out
16 Execution timed out 2000 ms 6108 KB Execution timed out
17 Execution timed out 2000 ms 6188 KB Execution timed out
18 Execution timed out 2000 ms 5644 KB Execution timed out
19 Execution timed out 2000 ms 6576 KB Execution timed out
20 Execution timed out 2000 ms 9708 KB Execution timed out