Submission #6907260


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int n, d[55][55], cum[55][55], ma[2505];

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> d[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cum[i+1][j+1] = cum[i][j+1] + cum[i+1][j] - cum[i][j] + d[i][j];
        }
    }
    for(int i1=0;i1<n;i1++){
        for(int j1=0;j1<n;j1++){
            for(int i2=i1+1;i2<=n;i2++){
                for(int j2=j1+1;j2<=n;j2++){
                    int s = (i2-i1)*(j2-j1);
                    ma[s] = max(ma[s], cum[i2][j2]-cum[i1][j2]-cum[i2][j1]+cum[i1][j1]);
                }
            }
        }
    }
    for(int i=0;i<n*n;i++){
        ma[i+1] = max(ma[i+1],ma[i]);
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int p;
        cin >> p;
        cout << ma[p] << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User NOSS
Language C++14 (GCC 5.4.1)
Score 100
Code Size 955 Byte
Status AC
Exec Time 10 ms
Memory 256 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 50 / 50
Status
AC × 18
AC × 20
Set Name Test Cases
Subtask1 sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Subtask2 rand0.txt, rand1.txt, rand2.txt, rand3.txt, rand4.txt, rand_max0.txt, rand_max1.txt, rand_max2.txt, rand_max3.txt, rand_max4.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Case Name Status Exec Time Memory
rand0.txt AC 4 ms 256 KB
rand1.txt AC 4 ms 256 KB
rand2.txt AC 6 ms 256 KB
rand3.txt AC 2 ms 256 KB
rand4.txt AC 1 ms 256 KB
rand_max0.txt AC 10 ms 256 KB
rand_max1.txt AC 9 ms 256 KB
rand_max2.txt AC 9 ms 256 KB
rand_max3.txt AC 9 ms 256 KB
rand_max4.txt AC 9 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
sub0.txt AC 1 ms 256 KB
sub1.txt AC 1 ms 256 KB
sub2.txt AC 1 ms 256 KB
sub_rand_max0.txt AC 1 ms 256 KB
sub_rand_max1.txt AC 1 ms 256 KB
sub_rand_max2.txt AC 1 ms 256 KB
sub_rand_max3.txt AC 1 ms 256 KB
sub_rand_min0.txt AC 1 ms 256 KB