답안 #91113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91113 2018-12-26T09:50:07 Z inom UFO (IZhO14_ufo) C++14
25 / 100
2000 ms 9660 KB
#include <stdio.h>
 
#define fi first
#define se second
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define in freopen("ufo.in", "r", stdin);
#define out freopen("ufo.out", "w", stdout);

using namespace std;
  
const int N = 100100;
const int MOD = 1e9;

int TN = 1;

int n, m, r, k, p;

void solve() {
    scanf("%d %d %d %d %d", &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++) {
            scanf("%d ", &a[i][j]);
        }
    }
    for (int i = 1; i <= k; i++) {
        char c; int x, h;
        scanf("%c %d %d", &c, &x, &h);   
        if (c == 'W' || c == 'E') {
            if (c == 'W') {
                int cnt = r, j = 1;
                while (j <= m && cnt > 0) {
                    if (a[x][j] >= h) {
                        a[x][j]--; cnt--;
                    }
                    j++;
                }    
            }
            else {
                int cnt = r, j = m;
                while (j >= 1 && cnt > 0) {
                    if (a[x][j] >= h) {
                        a[x][j]--; cnt--;
                    }
                    j--;
                }
            }
        }
        else {
            if (c == 'N') {
                int cnt = r, j = 1;
                while (j <= n && cnt > 0) {
                    if (a[j][x] >= h) {
                        a[j][x]--; cnt--;
                    }
                    j++;
                }
            }
            else {
                int cnt = r, j = n;
                while (j >= 1 && cnt > 0) {
                    if (a[j][x] >= h) {
                        a[j][x]--; cnt--;
                    }
                    j--;
                }
            }
        }
    }
    int ans = 0; p--;
    for (int i = 1; i + p <= n; i++) {
        for (int j = 1; j + p <= m; j++) {
            int sum = 0;
            for (int u = i; u <= i + p; u++) {
                for (int v = j; v <= j + p; v++) {
                    sum += a[u][v];
                }
            }
            if (ans < sum) {
                ans = sum;
            }
        }
    }
    printf("%d\n", ans);
    return;
}

signed main() {
    // ios_base::sync_with_stdio(0);
    // in; out; // cin >> TN;
    while (TN--) solve();
    return 0;
 }

Compilation message

ufo.cpp: In function 'void solve()':
ufo.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d %d", &n, &m, &r, &k, &p);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ufo.cpp:25:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d ", &a[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
ufo.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c %d %d", &c, &x, &h);   
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 452 KB Output is correct
2 Incorrect 2 ms 528 KB Output isn't correct
3 Correct 2 ms 528 KB Output is correct
4 Incorrect 5 ms 616 KB Output isn't correct
5 Incorrect 16 ms 616 KB Output isn't correct
6 Incorrect 91 ms 2364 KB Output isn't correct
7 Execution timed out 2053 ms 4508 KB Time limit exceeded
8 Execution timed out 2056 ms 4524 KB Time limit exceeded
9 Incorrect 1793 ms 4716 KB Output isn't correct
10 Correct 1685 ms 4716 KB Output is correct
11 Execution timed out 2055 ms 4716 KB Time limit exceeded
12 Correct 1189 ms 4732 KB Output is correct
13 Runtime error 96 ms 9560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Correct 571 ms 9560 KB Output is correct
15 Execution timed out 2051 ms 9560 KB Time limit exceeded
16 Execution timed out 2058 ms 9560 KB Time limit exceeded
17 Runtime error 126 ms 9660 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 80 ms 9660 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Execution timed out 2067 ms 9660 KB Time limit exceeded
20 Execution timed out 2081 ms 9660 KB Time limit exceeded