답안 #22809

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22809 2017-04-30T07:36:41 Z dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) Donut-shaped Enclosure (KRIII5_DE) C++
0 / 7
6 ms 5028 KB
//
// Created by Acka on 2017. 4. 30..
//

#include <stdio.h>
#include <algorithm>
using namespace std;

int acc[1001][1001];

int main(){
    int N, L, R; scanf("%d %d %d", &N, &L, &R);
    for(int i = 0, r, c, x; i < N; i++){
        scanf("%d %d %d", &r, &c, &x);
        acc[r][c] += x;
    }

    for(int i = 1; i <= 1000; i++)
        for(int j = 1; j <= 1000; j++)
            acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1] + acc[i][j];

    int b1, r1, t2, l2, b2, r2, out, in, ans = -1;
    for(int t1 = 1; t1 <= 1000; t1++) {
        if(1000 < (b1 = (t1 + 2 * R))) break;
        for (int l1 = 1; l1 <= 1000; l1++) {
            if(1000 < (r1 = (l1 + 2 * R))) break;
            t2 = t1 + R - L + 1, l2 = l1 + R - L + 1;
            b2 = t1 + R + L - 1, r2 = l1 + R + L - 1;
            out = acc[b1][r1] - acc[t1 - 1][r1] - acc[b1][l1 - 1] + acc[t1 - 1][l1 - 1];
            in = acc[b2][r2] - acc[t2 - 1][r2] - acc[b2][l2 - 1] + acc[t2 - 1][l2 - 1];
            ans = max(ans, out - in);
        }
    }

    printf("%d\n", ans);
    return 0;
}

Compilation message

DE.cpp: In function 'int main()':
DE.cpp:12:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N, L, R; scanf("%d %d %d", &N, &L, &R);
                                               ^
DE.cpp:14:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &r, &c, &x);
                                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5028 KB Output is correct
2 Incorrect 6 ms 5028 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5028 KB Output is correct
2 Incorrect 6 ms 5028 KB Output isn't correct
3 Halted 0 ms 0 KB -