답안 #337347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337347 2020-12-20T03:14:47 Z boykut UFO (IZhO14_ufo) C++14
25 / 100
2000 ms 10572 KB
#include <bits/stdc++.h>

using namespace std;

signed main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   
   int n, m, k, r, p;
   cin >> n >> m >> r >> k >> p;
   
   int a[n][m];
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
         cin >> a[i][j];
      }
   }
   
   for (int i = 0; i < k; i++) {
      char ch; cin >> ch;
      int pos, h; cin >> pos >> h;
      pos--;
      if (ch == 'N') {
         int cnt = 0;
         for (int i = 0; i < n; i++) {
            if (a[i][pos] >= h) {
               a[i][pos] --;
               cnt++;
               if (cnt == r) break;
            }
         }
      } else if (ch == 'E') {
         int cnt = 0;
         for (int i = m - 1; i >= 0; i--) {
            if (a[pos][i] >= h) {
               a[pos][i] --;
               cnt++;
               if (cnt == r) break;
            }
         }
      } else if (ch == 'W') {
         int cnt = 0;
         for (int i = 0; i < m; i++) {
            if (a[pos][i] >= h) {
               a[pos][i] --;
               cnt++;
               if (cnt == r) break;
            }
         }
      } else {
         for (int i = n - 1; i >= 0; i--) {
            int cnt = 0;
            if (a[i][pos] >= h) {
               a[i][pos] --;
               cnt++;
               if (cnt == r) break;
            }
         }
      }
   }
   
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        //cout << a[i][j] << ' ';
      }
      //cout << '\n';
   }
   
   int sum = 0, ans = 0;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
         if (i + p <= n && j + p <= m) {
            sum = 0;
            for (int i1 = i; i1 < i + p; i1++) {
               for (int j1 = j; j1 < j + p; j1++) {
                  sum += a[i1][j1];
               }
            }
            if (sum > ans) {
               //cout << i << ' ' << j << '\n';
               ans = sum;
               //cout << sum << "\n\n";
            }
         }
      }
   }
   
   cout << ans << '\n';
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Incorrect 5 ms 492 KB Output isn't correct
5 Correct 16 ms 1260 KB Output is correct
6 Correct 125 ms 5612 KB Output is correct
7 Execution timed out 2074 ms 10572 KB Time limit exceeded
8 Execution timed out 2073 ms 6984 KB Time limit exceeded
9 Execution timed out 2078 ms 7256 KB Time limit exceeded
10 Execution timed out 2057 ms 7112 KB Time limit exceeded
11 Execution timed out 2059 ms 6588 KB Time limit exceeded
12 Execution timed out 2083 ms 7404 KB Time limit exceeded
13 Execution timed out 2056 ms 6860 KB Time limit exceeded
14 Correct 1607 ms 7356 KB Output is correct
15 Execution timed out 2044 ms 8160 KB Time limit exceeded
16 Execution timed out 2080 ms 6704 KB Time limit exceeded
17 Execution timed out 2078 ms 10456 KB Time limit exceeded
18 Execution timed out 2065 ms 5848 KB Time limit exceeded
19 Execution timed out 2051 ms 6728 KB Time limit exceeded
20 Execution timed out 2061 ms 6380 KB Time limit exceeded